Storage

Safe way to pass ConnectionString to commands

  • Set the environment variable:

$env:AZURE_STORAGE_CONNECTION_STRING="DefaultEndpointsProtocol=..."
  • Use the value of the environment variable in azure cli or scripts by specifying the connection string as follows:

$env:AZURE_STORAGE_CONNECTION_STRING

List storage containers

az storage container list --connection-string "DefaultEndpointsProtocol=<protocol>;AccountName=<storage_name>;AccountKey=<secret_key>;EndpointSuffix=core.windows.net"

List all the blob files in a container

az storage blob list --container-name <container_name> --connection-string "DefaultEndpointsProtocol=<protocol>;AccountName=<storage_name>;AccountKey=<secret_key>;EndpointSuffix=core.windows.net"

Download a specific blob file

az storage blob download --container-name <container_name> --name <blob_name> --file <local_filename_folder> --connection-string "DefaultEndpointsProtocol=<protocol>;AccountName=<storage_name>;AccountKey=<secret_key>;EndpointSuffix=core.windows.net"

Download all the blob files in a container

az storage blob download-batch --source <container_name> --connection-string "DefaultEndpointsProtocol=<protocol>;AccountName=<storage_name>;AccountKey=<secret_key>;EndpointSuffix=core.windows.net"

Store the name of all the storage blobs in a CSV

Get all the storage blob files

  • List all the storage containers

  • Create a folder for each container under

  • Download all the files for each container

Last updated