21

I've installed azure-cli in the hope to use it to download an entire container from Azure storage. The info on the page gives clear examples on how to get a single blob, but not on how one downloads an entire container.

There is a 'azure storage blob download [parameters]'. Where is 'azure storage container download [parameters]'?

Evert
  • 1,395

4 Answers4

22

First, login with:

az login

Then download the files you need:

az storage blob download-batch -d . \
  --pattern *.* \
  -s MyContainer \
  --account-name storageAccountName
  --account-key storageAccountKey
2

Have you tried AZcopy?

AzCopy /Source:https://myaccount.file.core.windows.net/myfileshare/ /Dest:C:\myfolder /SourceKey:key /S
Worthwelle
  • 4,816
2

They added download-batch option. This is exactly what you need. See https://docs.microsoft.com/en-us/cli/azure/storage/blob?view=azure-cli-latest#az-storage-blob-download-batch

stej
  • 241
1

There is no single command in the Azure CLI that allows you to download all blobs from a container. You can achieve this via your own code as follows:

# Create a directory to store all the blobs
mkdir /downloaded-container && cd /downloaded-container

# Get all the blobs
BLOBS=$(az storage blob list -c $CONTAINER \
    --account-name $ACCOUNT_NAME --sas-token "$SAS_TOKEN" \
    --query [*].name --output tsv)

# Download each one
for BLOB in $BLOBS
do
  echo "********Downloading $BLOB"
  az storage blob download -n $BLOB -f $BLOB -c $CONTAINER --account-name $ACCOUNT_NAME --sas-token "$SAS_TOKEN"
done
Saca
  • 119