The az storage blob command is part of the azure-cli tool, which is the official Command-Line Interface (CLI) provided by Microsoft for managing Azure resources and services.
The az storage blob command allows you to manage blob storage containers and objects in Azure. Blob storage is a service in Azure that provides scalable storage for unstructured data such as images, videos, documents, logs, and more. Here’s an overview of its functionality:
- Container Creation: With the az storage container create subcommand, you can create a new blob storage container. Containers act as logical units to organize and manage blobs. You can specify the container name, access level, and other configurations.
- Container Management: The az storage container command provides various subcommands to manage blob storage containers. You can list containers, show their properties, set access policies, delete containers, and more.
- Blob Upload: Using the az storage blob upload subcommand, you can upload files or data from your local machine to a blob storage container. You need to specify the source file path, destination blob name, container name, and other parameters.
- Blob Download: The az storage blob download subcommand allows you to download blobs from a blob storage container to your local machine. You specify the source blob name, container name, and destination file path.
- Blob Listing: With the az storage blob list subcommand, you can retrieve a list of blobs in a container. This allows you to view the blob names, sizes, properties, and other details.
- Blob Management: The az storage blob command provides additional subcommands to manage individual blobs. You can show blob properties, set metadata, delete blobs, copy blobs between containers, generate shared access signatures (SAS), and more.
Azure Blob storage is designed to be highly scalable, durable, and accessible from anywhere. It offers various storage tiers, such as hot, cool, and archive, to optimize costs based on data access patterns and retention requirements.
az storage blob Command Examples
1. Download a blob to a file path:
# az storage blob download --account-name storage_account_name --account-key storage_account_key -c container_name -n /path/to/blob -f path/to/local_file
2. Download blobs from a blob container recursively:
# az storage blob download-batch --account-name storage_account_name --account-key storage_account_key -s container_name -d path/to/remote --pattern filename_regex --destination /path/to/destination
3. Upload a local file to blob storage:
# az storage blob upload --account-name storage_account_name --account-key storage_account_key -c container_name -n /path/to/blob -f /path/to/local_file
4. Delete a blob object:
# az storage blob delete --account-name storage_account_name --account-key storage_account_key -c container_name -n /path/to/blob
5. Generate a shared access signature for a blob:
# az storage blob generate-sas --account-name storage_account_name --account-key storage_account_key -c container_name -n /path/to/blob --permissions permission_set --expiry Y-m-d'T'H:M'Z' --https-only