az storage blob directory

Manage blob directories in storage account container.

To use the directory commands, please make sure your storage account type is StorageV2.

Commands

az storage blob directory access

Manage the access control properties of a directory when Hierarchical Namespace is enabled.

az storage blob directory access set

Set the access control properties of a directory.

az storage blob directory access show

Show the access control properties of a directory.

az storage blob directory access update

Update the access control properties of a directory.

az storage blob directory create

Create a storage blob directory in a storage container.

az storage blob directory delete

Delete a storage blob directory in a storage container.

az storage blob directory download

Download blobs to a local file path.

az storage blob directory exists

Check for the existence of a blob directory in a storage container.

az storage blob directory list

List blobs and blob subdirectories in a storage directory.

az storage blob directory metadata

Manage directory metadata.

az storage blob directory metadata show

Show all user-defined metadata for the specified blob directory.

az storage blob directory metadata update

Set user-defined metadata for the specified blob directory as one or more name-value pairs.

az storage blob directory move

Move a storage directory to another storage blob directory in a storage container.

az storage blob directory show

Show a storage blob directory properties in a storage container.

az storage blob directory upload

Upload blobs or subdirectories to a storage blob directory.

az storage blob directory create

Create a storage blob directory in a storage container.

Create a storage blob directory which can contain other directories or blobs in a storage container.

az storage blob directory create --container-name
                                 --directory-path
                                 [--account-key]
                                 [--account-name]
                                 [--auth-mode {key, login}]
                                 [--connection-string]
                                 [--lease-id]
                                 [--metadata]
                                 [--permissions]
                                 [--sas-token]
                                 [--timeout]
                                 [--umask]

Examples

Create a storage blob directory in a storage container.

az storage blob directory create -c MyContainer -d MyDirectoryPath --account-name MyStorageAccount

Create a storage blob directory with permissions and umask.

az storage blob directory create -c MyContainer -d MyDirectoryPath --account-name MyStorageAccount --permissions rwxrwxrwx --umask 0000

Required Parameters

--container-name -c

The container name.

--directory-path -d

The directory path 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.

--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.

--lease-id

Required if the directory to be overwritten has an active lease.

--metadata

Metadata in space-separated key=value pairs. This overwrites any existing metadata.

--permissions

Optional and only valid if Hierarchical Namespace is enabled for the account. Sets POSIX access permissions for the file owner, the file owning group, and others. Each class may be granted read, write, or execute permission. The sticky bit is also supported. Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported.

--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.

--umask

Optional and only valid if Hierarchical Namespace is enabled for the account. The umask restricts permission settings for file and directory, and will only be applied when default Acl does not exist in parent directory. If the umask bit has set, it means that the corresponding permission will be disabled. In this way, the resulting permission is given by p & ^u, where p is the permission and u is the umask. Only 4-digit octal notation (e.g. 0022) is supported here.

default value: 0027

az storage blob directory delete

Delete a storage blob directory in a storage container.

This operation's behavior is different depending on whether Hierarchical Namespace is enabled; if yes, then the delete operation can be atomic and instantaneous; if not, the operation is performed in batches and a continuation token could be returned.

az storage blob directory delete --container-name
                                 --directory-path
                                 [--account-key]
                                 [--account-name]
                                 [--auth-mode {key, login}]
                                 [--connection-string]
                                 [--fail-not-exist]
                                 [--if-match]
                                 [--if-modified-since]
                                 [--if-none-match]
                                 [--if-unmodified-since]
                                 [--lease-id]
                                 [--marker]
                                 [--recursive]
                                 [--sas-token]
                                 [--timeout]

Examples

Delete a storage blob directory in a storage container.

az storage blob directory delete -c MyContainer -d MyDirectoryPath --account-name MyStorageAccount

Required Parameters

--container-name -c

The container name.

--directory-path -d

The directory path 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.

--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.

--fail-not-exist

Specify whether to throw an exception when the directory doesn't exist.

--if-match

An ETag value, or the wildcard character (*). Specify this header to perform the operation only if the resource's ETag matches the value specified.

--if-modified-since

Alter only if modified since supplied UTC datetime (Y-m-d'T'H:M'Z').

--if-none-match

An ETag value, or the wildcard character (*). Specify this header to perform the operation only if the resource's ETag does not match the value specified.

--if-unmodified-since

Alter only if unmodified since supplied UTC datetime (Y-m-d'T'H:M'Z').

--lease-id

Required if the directory has an active lease.

--marker

Optional. When deleting a directory without the Hierarchical Namespace, the number of paths that are deleted with each invocation is limited. If the number of paths to be deleted exceeds this limit, a continuation token is returned. When a continuation token is returned, it must be specified in a subsequent invocation of the delete operation to continue deleting the directory.

--recursive

If "true", all paths beneath the directory will be deleted. If "false" and the directory is non-empty, an error occurs.

--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.

az storage blob directory download

Download blobs to a local file path.

az storage blob directory download --container
                                   --destination-path
                                   --source-path
                                   [--account-key]
                                   [--account-name]
                                   [--auth-mode {key, login}]
                                   [--connection-string]
                                   [--recursive]
                                   [--sas-token]

Examples

Download a single blob in a storage blob directory.

az storage blob directory download -c MyContainer --account-name MyStorageAccount -s "path/to/blob" -d "<local-path>"

Download the entire directory in a storage container.

az storage blob directory download -c MyContainer --account-name MyStorageAccount -s SourceDirectoryPath -d "<local-path>" --recursive

Download an entire subdirectory of a storage blob directory.

az storage blob directory download -c MyContainer --account-name MyStorageAccount -s "path/to/subdirectory" -d "<local-path>" --recursive

Required Parameters

--container -c

The download source container.

--destination-path -d

The destination local directory path to download.

--source-path -s

The download source directory path. It should be an absolute path to container.

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.

--recursive -r

Recursively download blobs. If enabled, all the blobs including the blobs in subdirectories will be downloaded.

--sas-token

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

az storage blob directory exists

Check for the existence of a blob directory in a storage container.

az storage blob directory exists --container-name
                                 --directory-path
                                 [--account-key]
                                 [--account-name]
                                 [--auth-mode {key, login}]
                                 [--connection-string]
                                 [--sas-token]
                                 [--snapshot]
                                 [--timeout]

Examples

Check for the existence of a blob directory in a storage container.

az storage blob directory exists -c MyContainer -d MyDirectoryPath --account-name MyStorageAccount

Required Parameters

--container-name -c

The container name.

--directory-path -d

The directory path 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.

--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.

--sas-token

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

--snapshot

The snapshot parameter is an opaque DateTime value that, when present, specifies the snapshot.

--timeout

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

az storage blob directory list

List blobs and blob subdirectories in a storage directory.

az storage blob directory list --container-name
                               --directory-path
                               [--account-key]
                               [--account-name]
                               [--auth-mode {key, login}]
                               [--connection-string]
                               [--delimiter]
                               [--include]
                               [--marker]
                               [--num-results]
                               [--prefix]
                               [--sas-token]
                               [--timeout]

Examples

List blobs and blob subdirectories in a storage directory.

az storage blob directory list -c MyContainer -d DestinationDirectoryPath --account-name MyStorageAccount

Required Parameters

--container-name -c

The container name.

--directory-path -d

The directory path 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.

--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.

--delimiter

When the request includes this parameter, the operation returns a BlobPrefix element in the result list that acts as a placeholder for all blobs whose names begin with the same substring up to the appearance of the delimiter character. The delimiter may be a single character or a string.

--include

Specifies one or more additional datasets to include in the response.

default value: mc
--marker

An opaque continuation token. This value can be retrieved from the next_marker field of a previous generator object if num_results was specified and that generator has finished enumerating results. If specified, this generator will begin returning results from the point where the previous generator stopped.

--num-results

Specifies the maximum number of results to return. Provide "*" to return all.

default value: 5000
--prefix

Filters the results to return only blobs whose names begin 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.

--timeout

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

az storage blob directory move

Move a storage directory to another storage blob directory in a storage container.

Move a storage directory and all its content (which can contain other directories or blobs) to another storage blob directory in a storage container. This operation's behavior is different depending on whether Hierarchical Namespace is enabled; if yes, the move operation is atomic and no marker is returned; if not, the operation is performed in batches and a continuation token could be returned.

az storage blob directory move --container-name
                               --destination-path
                               --source-path
                               [--account-key]
                               [--account-name]
                               [--auth-mode {key, login}]
                               [--connection-string]
                               [--lease-id]
                               [--move-mode {legacy, posix}]
                               [--sas-token]
                               [--source-if-match]
                               [--source-if-modified-since]
                               [--source-if-none-match]
                               [--source-if-unmodified-since]
                               [--source-lease-id]
                               [--timeout]

Examples

Move a storage directory to another storage blob directory in a storage container.

az storage blob directory move -c MyContainer -d my-new-directory -s dir --account-name MyStorageAccount

Move a storage subdirectory to another storage blob directory in a storage container.

az storage blob directory move -c MyContainer -d my-new-directory -s dir/subdirectory --account-name MyStorageAccount

Required Parameters

--container-name -c

The container name.

--destination-path -d

The destination blob directory path. It can be a directory or subdirectory name, e.g. dir, dir/subdir. If the destination path exists and is empty, the source will be moved into the destination path. If the destination path does not exist, the destination path will be created and overwritten by the source. To control the move operation for nonempty path, you can use --move-mode to determine its behavior.

--source-path -s

The source blob directory path.

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.

--lease-id

A lease ID for destination directory_path. The destination directory_path must have an active lease and the lease ID must match.

--move-mode

Valid only when namespace is enabled. This parameter determines the behavior of the move operation. If the destination directory is empty, for both two mode, the destination directory will be overwritten. But if the destination directory is not empty, in legacy mode the move operation will fail and in posix mode, the source directory will be moved into the destination directory.

accepted values: legacy, posix
default value: posix
--sas-token

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

--source-if-match

Optional. An ETag value. Specify this header to perform the move operation only if the source's ETag matches the value specified.

--source-if-modified-since

Optional. A date and time value. Specify this header to perform the move operation only if the source has been modified since the specified date and time.

--source-if-none-match

Optional. An ETag value or the special wildcard ("*") value. Specify this header to perform the move operation only if the source's ETag does not match the value specified.

--source-if-unmodified-since

Optional. A date and time value. Specify this header to perform the move operation only if the source has not been modified since the specified date and time.

--source-lease-id

Optional. A lease ID for the source_path. The source_path must have an active lease and the lease ID must match.

--timeout

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

az storage blob directory show

Show a storage blob directory properties in a storage container.

az storage blob directory show --container-name
                               --directory-path
                               [--account-key]
                               [--account-name]
                               [--auth-mode {key, login}]
                               [--connection-string]
                               [--if-match]
                               [--if-modified-since]
                               [--if-none-match]
                               [--if-unmodified-since]
                               [--lease-id]
                               [--sas-token]
                               [--timeout]

Examples

Show a storage blob directory properties in a storage container.

az storage blob directory show -c MyContainer -d MyDirectoryPath --account-name MyStorageAccount

Required Parameters

--container-name -c

The container name.

--directory-path -d

The directory path 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.

--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.

--if-match

An ETag value, or the wildcard character (*). Specify this header to perform theoperation only if the resource's ETag matches the value specified.

--if-modified-since

Alter only if modified since supplied UTC datetime (Y-m-d'T'H:M'Z').

--if-none-match

An ETag value, or the wildcard character (*). Specify this header to performthe operation only if the resource's ETag does not match the value specified. Specify the wildcardcharacter (*) to perform the operation only if the resource does not exist, and fail the operationif it does exist.

--if-unmodified-since

Alter only if unmodified since supplied UTC datetime (Y-m-d'T'H:M'Z').

--lease-id

Required if the blob has an active lease.

--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.

az storage blob directory upload

Upload blobs or subdirectories to a storage blob directory.

az storage blob directory upload --container
                                 --destination-path
                                 --source
                                 [--account-key]
                                 [--account-name]
                                 [--auth-mode {key, login}]
                                 [--connection-string]
                                 [--recursive]
                                 [--sas-token]

Examples

Upload a single blob to a storage blob directory.

az storage blob directory upload -c MyContainer --account-name MyStorageAccount -s "path/to/file" -d directory

Upload a local directory to a storage blob directory.

az storage blob directory upload -c MyContainer --account-name MyStorageAccount -s "path/to/directory" -d directory --recursive

Upload a set of files in a local directory to a storage blob directory.

az storage blob directory upload -c MyContainer --account-name MyStorageAccount -s "path/to/file*" -d directory --recursive

Required Parameters

--container -c

The upload destination container.

--destination-path -d

The upload destination directory path. It should be an absolute path to container. If the specified destination path does not exist, a new directory path will be created.

--source -s

The source file path to upload from.

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.

--recursive -r

Recursively upload blobs. If enabled, all the blobs including the blobs in subdirectories will be uploaded.

--sas-token

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