Azure CLI Storage Commands
The Azure CLI provides a rich set of commands for managing Azure Storage services. These commands allow you to interact with blobs, files, queues, and tables from your terminal.
Blob Storage Management
Commands for managing blob containers and individual blobs.
Creating and Listing Containers
az storage container create --name mycontainer --account-name mystorageaccount --auth-mode login
Example: Creates a new blob container named 'mycontainer' in the storage account 'mystorageaccount'.
az storage container list --account-name mystorageaccount --auth-mode login --output table
Example: Lists all blob containers in the specified storage account, formatted as a table.
Uploading and Downloading Blobs
az storage blob upload --account-name mystorageaccount --container-name mycontainer --name myblob.txt --file ./local/path/to/myblob.txt --auth-mode login
Example: Uploads a local file to a blob in the specified container.
az storage blob download --account-name mystorageaccount --container-name mycontainer --name myblob.txt --file ./local/path/to/downloaded.txt --auth-mode login
Example: Downloads a blob from a container to a local file.
Managing Blobs
az storage blob delete --account-name mystorageaccount --container-name mycontainer --name myblob.txt --auth-mode login
Example: Deletes a specific blob.
az storage blob list --account-name mystorageaccount --container-name mycontainer --output table
Example: Lists all blobs within a container.
File Share Management
Commands for managing Azure File shares, directories, and files.
Creating and Listing File Shares
az storage share create --name myfileshare --account-name mystorageaccount --auth-mode login
Example: Creates a new file share.
az storage share list --account-name mystorageaccount --output table
Example: Lists all file shares in the storage account.
Uploading and Downloading Files
az storage file upload --account-name mystorageaccount --share-name myfileshare --path /mydirectory/myfile.txt --file ./local/path/to/myfile.txt --auth-mode login
Example: Uploads a local file to a specified path within a file share.
az storage file download --account-name mystorageaccount --share-name myfileshare --path /mydirectory/myfile.txt --file ./local/path/to/downloaded.txt --auth-mode login
Example: Downloads a file from a file share.
Queue Management
Commands for managing Azure Storage Queues.
Creating and Listing Queues
az storage queue create --name myqueue --account-name mystorageaccount --auth-mode login
Example: Creates a new queue.
az storage queue list --account-name mystorageaccount --output table
Example: Lists all queues in the storage account.
Queue Operations
az storage message put --account-name mystorageaccount --queue-name myqueue --content "Hello, Azure Queue!" --auth-mode login
Example: Adds a message to a queue.
az storage message peek --account-name mystorageaccount --queue-name myqueue --auth-mode login
Example: Peeks at the next message in a queue without removing it.
az storage message get --account-name mystorageaccount --queue-name myqueue --auth-mode login
Example: Retrieves and removes the next message from a queue.
Table Management
Commands for managing Azure Table Storage entities.
Creating and Listing Tables
az storage table create --name mytable --account-name mystorageaccount --auth-mode login
Example: Creates a new table.
az storage table list --account-name mystorageaccount --output table
Example: Lists all tables in the storage account.
Entity Operations
az storage entity insert --account-name mystorageaccount --table-name mytable --entity '{"PartitionKey":"PK1", "RowKey":"1", "Name":"Alice", "Age":30}' --auth-mode login
Example: Inserts a new entity into a table.
az storage entity query --account-name mystorageaccount --table-name mytable --filter "Name eq 'Alice'" --auth-mode login
Example: Queries entities in a table using a filter.
For more detailed information and advanced options, please refer to the official Azure CLI storage documentation.