2021-10-05 09:51:12 -07:00
|
|
|
# az storage blob
|
|
|
|
|
|
|
|
> Manage blob storage containers and objects in Azure.
|
2023-10-15 09:42:29 +02:00
|
|
|
> Part of `azure-cli` (also known as `az`).
|
2022-10-04 20:36:23 +05:30
|
|
|
> More information: <https://learn.microsoft.com/cli/azure/storage/blob>.
|
2021-10-05 09:51:12 -07:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Download a blob to a file path specifying a source container:
|
2021-10-05 09:51:12 -07:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`az storage blob download --account-name {{storage_account_name}} --account-key {{storage_account_key}} {{[-c|--container-name]}} {{container_name}} {{[-n|--name]}} {{path/to/blob}} {{[-f|--file]}} {{path/to/local_file}}`
|
2021-10-05 09:51:12 -07:00
|
|
|
|
2024-02-09 11:34:08 -03:00
|
|
|
- [d]ownload blobs from a blob container recursively:
|
2021-10-05 09:51:12 -07:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`az storage blob download-batch --account-name {{storage_account_name}} --account-key {{storage_account_key}} {{[-s|--source]}} {{container_name}} {{[-d|--destination]}} {{path/to/remote}} --pattern {{filename_regex}} {{[-d|--destination]}} {{path/to/destination}}`
|
2021-10-05 09:51:12 -07:00
|
|
|
|
|
|
|
- Upload a local file to blob storage:
|
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`az storage blob upload --account-name {{storage_account_name}} --account-key {{storage_account_key}} {{[-c|--container-name]}} {{container_name}} {{[-n|--name]}} {{path/to/blob}} {{[-f|--file]}} {{path/to/local_file}}`
|
2021-10-05 09:51:12 -07:00
|
|
|
|
|
|
|
- Delete a blob object:
|
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`az storage blob delete --account-name {{storage_account_name}} --account-key {{storage_account_key}} {{[-c|--container-name]}} {{container_name}} {{[-n|--name]}} {{path/to/blob}}`
|
2021-10-05 09:51:12 -07:00
|
|
|
|
|
|
|
- Generate a shared access signature for a blob:
|
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`az storage blob generate-sas --account-name {{storage_account_name}} --account-key {{storage_account_key}} {{[-c|--container-name]}} {{container_name}} {{[-n|--name]}} {{path/to/blob}} --permissions {{permission_set}} --expiry {{Y-m-d'T'H:M'Z'}} --https-only`
|