az storage container

Manage blob storage containers.

Please specify one of the following authentication parameters for your commands: --auth-mode, --account-key, --connection-string, --sas-token. You also can use corresponding environment variables to store your authentication credentials, e.g. AZURE_STORAGE_KEY, AZURE_STORAGE_CONNECTION_STRING and AZURE_STORAGE_SAS_TOKEN.

Commands

az storage container generate-sas

Generate a SAS token for a storage container.

az storage container list

List containers in a storage account.

az storage container restore

Restores soft-deleted container.

az storage container generate-sas

Generate a SAS token for a storage container.

az storage container generate-sas --name
                                  [--account-key]
                                  [--account-name]
                                  [--as-user]
                                  [--auth-mode {key, login}]
                                  [--cache-control]
                                  [--connection-string]
                                  [--content-disposition]
                                  [--content-encoding]
                                  [--content-language]
                                  [--content-type]
                                  [--expiry]
                                  [--full-uri]
                                  [--https-only]
                                  [--ip]
                                  [--permissions]
                                  [--policy-name]
                                  [--start]

Examples

Generate a sas token for blob container and use it to upload a blob.

end=`date -u -d "30 minutes" '+%Y-%m-%dT%H:%MZ'`
sas=`az storage container generate-sas -n mycontainer --https-only --permissions dlrw --expiry $end -o tsv`
az storage blob upload -n MyBlob -c mycontainer -f file.txt --sas-token $sas

Generate a shared access signature for the container (autogenerated)

az storage container generate-sas --account-key 00000000 --account-name mystorageaccount --expiry 2020-01-01 --name mycontainer --permissions dlrw

Generate a SAS token for a storage container. (autogenerated)

az storage container generate-sas --account-name mystorageaccount --as-user --auth-mode login --expiry 2020-01-01 --name container1 --permissions dlrw

Required Parameters

--name -n

The container name.

Optional Parameters

--account-key

Storage account key. Must be used in conjunction with storage account name. Environment variable: AZURE_STORAGE_KEY.

--account-name

Storage account name. Related environment variable: AZURE_STORAGE_ACCOUNT. Must be used in conjunction with either storage account key or a SAS token. If neither are present, the command will try to query the storage account key using the authenticated Azure account. If a large number of storage commands are executed the API quota may be hit.

--as-user

Indicates that this command return the SAS signed with the user delegation key. The expiry parameter and '--auth-mode login' are required if this argument is specified.

--auth-mode

The mode in which to run the command. "login" mode will directly use your login credentials for the authentication. The legacy "key" mode will attempt to query for an account key if no authentication parameters for the account are provided. Environment variable: AZURE_STORAGE_AUTH_MODE.

accepted values: key, login
--cache-control

Response header value for Cache-Control when resource is accessedusing this shared access signature.

--connection-string

Storage account connection string. Environment variable: AZURE_STORAGE_CONNECTION_STRING.

--content-disposition

Response header value for Content-Disposition when resource is accessedusing this shared access signature.

--content-encoding

Response header value for Content-Encoding when resource is accessedusing this shared access signature.

--content-language

Response header value for Content-Language when resource is accessedusing this shared access signature.

--content-type

Response header value for Content-Type when resource is accessedusing this shared access signature.

--expiry

Specifies the UTC datetime (Y-m-d'T'H:M'Z') at which the SAS becomes invalid. Do not use if a stored access policy is referenced with --id that specifies this value.

--full-uri

Indicate that this command return the full blob URI and the shared access signature token.

--https-only

Only permit requests made with the HTTPS protocol. If omitted, requests from both the HTTP and HTTPS protocol are permitted.

--ip

Specifies the IP address or range of IP addresses from which to accept requests. Supports only IPv4 style addresses.

--permissions

The permissions the SAS grants. Allowed values: (d)elete (x)delete_previous_version (l)ist (r)ead (t)ag (w)rite. Do not use if a stored access policy is referenced with --policy-name that specifies this value. Can be combined.

--policy-name

The name of a stored access policy within the container's ACL.

--start

Specifies the UTC datetime (Y-m-d'T'H:M'Z') at which the SAS becomes valid. Do not use if a stored access policy is referenced with --id that specifies this value. Defaults to the time of the request.

az storage container list

List containers in a storage account.

az storage container list [--account-key]
                          [--account-name]
                          [--auth-mode {key, login}]
                          [--connection-string]
                          [--include-deleted {false, true}]
                          [--include-metadata {false, true}]
                          [--marker]
                          [--num-results]
                          [--prefix]
                          [--sas-token]
                          [--show-next-marker]
                          [--timeout]

Optional Parameters

--account-key

Storage account key. Must be used in conjunction with storage account name. Environment variable: AZURE_STORAGE_KEY.

--account-name

Storage account name. Related environment variable: AZURE_STORAGE_ACCOUNT. Must be used in conjunction with either storage account key or a SAS token. If neither are present, the command will try to query the storage account key using the authenticated Azure account. If a large number of storage commands are executed the API quota may be hit.

--auth-mode

The mode in which to run the command. "login" mode will directly use your login credentials for the authentication. The legacy "key" mode will attempt to query for an account key if no authentication parameters for the account are provided. Environment variable: AZURE_STORAGE_AUTH_MODE.

accepted values: key, login
--connection-string

Storage account connection string. Environment variable: AZURE_STORAGE_CONNECTION_STRING.

--include-deleted

Specify that deleted containers to be returned in the response. This is for container restore enabled account. The default value is False.

accepted values: false, true
--include-metadata

Specify that container metadata to be returned in the response.

accepted values: false, true
--marker

A string value that identifies the portion of the list of containers to be returned with the next listing operation. The operation returns the NextMarker value within the response body if the listing operation did not return all containers remaining to be listed with the current page. If specified, this generator will begin returning results from the point where the previous generator stopped.

--num-results

Specify the maximum number to return. If the request does not specify num_results, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the listing operation crosses a partition boundary, then the service will return a continuation token for retrieving the remaining of the results. Provide "*" to return all.

default value: 5000
--prefix

Filter the results to return only blobs whose name begins with the specified prefix.

--sas-token

A Shared Access Signature (SAS). Must be used in conjunction with storage account name. Environment variable: AZURE_STORAGE_SAS_TOKEN.

--show-next-marker

Show nextMarker in result when specified.

--timeout

Request timeout in seconds. Applies to each call to the service.

az storage container restore

Restores soft-deleted container.

Operation will only be successful if used within the specified number of days set in the delete retention policy. .. versionadded:: 12.4.0 This operation was introduced in API version '2019-12-12'.

az storage container restore --deleted-version
                             --name
                             [--account-key]
                             [--account-name]
                             [--auth-mode {key, login}]
                             [--connection-string]
                             [--new-name]
                             [--sas-token]
                             [--timeout]

Required Parameters

--deleted-version

Specify the version of the deleted container to restore.

--name -n

Specify the name of the deleted container to restore.

Optional Parameters

--account-key

Storage account key. Must be used in conjunction with storage account name. Environment variable: AZURE_STORAGE_KEY.

--account-name

Storage account name. Related environment variable: AZURE_STORAGE_ACCOUNT. Must be used in conjunction with either storage account key or a SAS token. If neither are present, the command will try to query the storage account key using the authenticated Azure account. If a large number of storage commands are executed the API quota may be hit.

--auth-mode

The mode in which to run the command. "login" mode will directly use your login credentials for the authentication. The legacy "key" mode will attempt to query for an account key if no authentication parameters for the account are provided. Environment variable: AZURE_STORAGE_AUTH_MODE.

accepted values: key, login
--connection-string

Storage account connection string. Environment variable: AZURE_STORAGE_CONNECTION_STRING.

--new-name

The new name for the deleted container to be restored to.

--sas-token

A Shared Access Signature (SAS). Must be used in conjunction with storage account name. Environment variable: AZURE_STORAGE_SAS_TOKEN.

--timeout

Request timeout in seconds. Applies to each call to the service.