Using the az cli within an azvm, I want to be able to list all the files within a specific container blob and then download those files. Let's say I have a container 'top' and then it has several subdirectories such as:
top/sub1/sub2/sub3/
Where in the folder sub3, there are multiple files. I would like to:
List all the files in sub3, and then
Retrieve all of the files in sub3 through the az cli.
I can only list the contents within 'top' with the command:
az storage container list --account-key ${key} --account-name top --query "[].{Name:name}" --output table
CodePudding user response:
az storage container list
--> is used to list the containers inside a storage account.
Based on the shared information, we have understood that you are trying to list the blob under the subdirectories(sub1/sub2/sub3) inside a contianer top
then you need to use az storage blob directory list
cmdlet which is used to List blobs and blob subdirectories in a storage directory.
To test this we have created a storage account with one container (top) and having multiple subdirectories(sub1/sub2/sub3) and we have used the below cmdlet to list the blob inside them.
az storage blob directory list -c top -d sub1/sub2/sub3 --account-name <storageAccountName> --query [].name -o table
Here is the sample output for reference:
Reference documentation for more information about az storage blob directory list cmdlet.