Azure CLI Storage Commands

The Azure CLI provides a rich set of commands for managing Azure Storage resources. This documentation details the commands available for interacting with various Azure Storage services.

Storage Account Management

Manage your Azure Storage accounts, which serve as containers for your data objects like blobs, files, queues, and tables.

Creating a Storage Account

Use the az storage account create command to provision a new storage account. You need to specify a unique name, resource group, and location.

az storage account create --name mystorageaccountname --resource-group MyResourceGroup --location westus --sku Standard_LRS

Parameters:

  • --name: The name for your storage account (globally unique).
  • --resource-group: The name of the resource group.
  • --location: The Azure region.
  • --sku: The performance and replication option (e.g., Standard_LRS, Standard_GRS, Premium_LRS).

Listing Storage Accounts

To view all storage accounts within a subscription or resource group, use the az storage account list command.

az storage account list --resource-group MyResourceGroup
az storage account list

Showing Storage Account Details

Get detailed information about a specific storage account using its name and resource group.

az storage account show --name mystorageaccountname --resource-group MyResourceGroup

Deleting a Storage Account

Remove a storage account and all its contents. Use with caution.

az storage account delete --name mystorageaccountname --resource-group MyResourceGroup
Important: Storage account names must be globally unique and consist of 3-24 alphanumeric characters.

Accessing Storage Account Keys

You often need storage account keys to authenticate with storage services. Use the az storage account keys list command.

az storage account keys list --account-name mystorageaccountname --resource-group MyResourceGroup

The output will include both key1 and key2.

Connecting to Storage Accounts

For many storage commands, you can connect to a specific storage account by providing its name and key, or by using connection strings.

Using Account Name and Key

Most storage commands accept --account-name and --account-key parameters.

Using Connection String

Alternatively, you can use a connection string, which can be obtained from the Azure portal or by listing storage account keys.

az storage blob list --connection-string "DefaultEndpointsProtocol=https;AccountName=mystorageaccountname;AccountKey=..."

Further Storage Services

Explore the specific commands for different Azure Storage services:

Tip: Use the az storage --help command to get a list of all available storage subcommands and their descriptions.