This guide explains how to download blobs from Azure Blob Storage using the Azure Command-Line Interface (CLI).
az login.az storage blob download CommandThe primary command for downloading blobs is az storage blob download. It offers flexibility in specifying the blob and the destination for the download.
To download a single blob to the current directory:
az storage blob download --container-name --name --file
--container-name: The name of the container where the blob resides.--name: The name of the blob to download.--file: The local file path where the blob content will be saved. If omitted, it defaults to the blob name in the current directory.Let's say you have a blob named report.csv in a container named my-reports and you want to download it to your local machine as ~/downloads/report_final.csv.
az storage blob download --container-name my-reports --name report.csv --file ~/downloads/report_final.csv
You can also download the blob content directly to standard output (stdout), which is useful for piping the output to other commands.
az storage blob download --container-name --name --file -
The - for the --file argument signifies stdout.
If you need to specify the storage account key instead of logging in via az login:
az storage blob download --account-name --account-key --container-name --name --file
If you have a SAS URL for the blob, you can use it to download the blob without needing account credentials directly.
az storage blob download --url --file
By default, the command will fail if the destination file already exists. You can use the --overwrite flag to allow overwriting.
az storage blob download --container-name --name --file --overwrite
The Azure CLI typically shows progress for downloads. If you want to disable it or control its behavior, you can use the --progress parameter (though it's usually on by default).
--container-name and --name for typos and case sensitivity.For more detailed information and options, refer to the official Azure CLI documentation.