Cuir in eagar

Comhroinn trí


Replace blob properties and metadata by using AzCopy v10

You can use AzCopy to change the access tier of one or more blobs and replace (overwrite) the metadata, and index tags of one or more blobs.

Get started

See the Get started with AzCopy article to download AzCopy and learn about the ways that you can provide authorization credentials to the storage service.

Note

The examples in this article assume that you've provided authorization credentials by using Microsoft Entra ID.

If you'd rather use a SAS token to authorize access to blob data, then you can append that token to the resource URL in each AzCopy command. For example: 'https://<storage-account-name>.blob.core.windows.net/<container-name><SAS-token>'.

Change the access tier

To change the access tier of a blob, use the azcopy set-properties command and set the -block-blob-tier parameter to the name of the access tier.

Tip

This example encloses path arguments with single quotes (''). Use single quotes in all command shells except for the Windows Command Shell (cmd.exe). If you're using a Windows Command Shell (cmd.exe), enclose path arguments with double quotes ("") instead of single quotes ('').

Syntax

azcopy set-properties 'https://<storage-account-name>.blob.core.windows.net/<container-name>/<blob-name>' --block-blob-tier=<access-tier>

Example

azcopy set-properties 'https://mystorageaccount.blob.core.windows.net/mycontainer/myTextFile.txt' --block-blob-tier=hot

To change the access tier for all blobs in a virtual directory, refer to the virtual directory name instead of the blob name, and then append --recursive=true to the command.

Example

azcopy set-properties 'https://mystorageaccount.blob.core.windows.net/mycontainer/myvirtualdirectory' --block-blob-tier=hot --recursive=true

To rehydrate a blob from the archive tier to an online tier, set the --rehydrate-priority to standard or high. By default, this parameter is set to standard. To learn more about the trade offs of each option, see Rehydration priority.

Example

azcopy set-properties 'https://mystorageaccount.blob.core.windows.net/mycontainer/myTextFile.txt' --block-blob-tier=hot --rehydrate-priority=high

Replace metadata

To replace the metadata of a blob, use the azcopy set-properties command and set the --metadata parameter to one or more key-value pairs.

Tip

This example encloses path arguments with single quotes (''). Use single quotes in all command shells except for the Windows Command Shell (cmd.exe). If you're using a Windows Command Shell (cmd.exe), enclose path arguments with double quotes ("") instead of single quotes ('').

Syntax

azcopy set-properties 'https://<storage-account-name>.blob.core.windows.net/<container-name>/<blob-name>' --metadata=<key>=<value>;<key>=<value>

Example

azcopy set-properties 'https://mystorageaccount.blob.core.windows.net/mycontainer/myTextFile.txt' --metadata=mykey1=myvalue1;mykey2=myvalue2

To replace the metadata for all blobs in a virtual directory, refer to the virtual directory name instead of the blob name, and then append --recursive=true to the command.

Example

azcopy set-properties 'https://mystorageaccount.blob.core.windows.net/mycontainer/myvirtualdirectory' --metadata=mykey1=myvalue1;mykey2=myvalue2 --recursive=true

To clear metadata, omit the tags and append --metadata=clear to the end of the command.

Example

azcopy set-properties 'https://mystorageaccount.blob.core.windows.net/mycontainer/myTextFile.txt' --metadata=clear

Replace index tags

To replace the index tags of a blob, use the azcopy set-properties command and set the --blob-tags parameter to one or more key-value pairs. Setting blob index tags can be performed by the Storage Blob Data Owner and by anyone with a Shared Access Signature that has permission to access the blob's tags (the t SAS permission). In addition, RBAC users with the Microsoft.Storage/storageAccounts/blobServices/containers/blobs/tags/write permission can perform this operation.

Tip

This example encloses path arguments with single quotes (''). Use single quotes in all command shells except for the Windows Command Shell (cmd.exe). If you're using a Windows Command Shell (cmd.exe), enclose path arguments with double quotes ("") instead of single quotes ('').

Syntax

azcopy set-properties 'https://<storage-account-name>.blob.core.windows.net/<container-name>/<blob-name>' --blob-tags=<tag>=<value>;<tag>=<value>

Example

azcopy set-properties 'https://mystorageaccount.blob.core.windows.net/mycontainer/myTextFile.txt' --blob-tags=mytag1=mytag1value;mytag2=mytag2value

To replace the index tags for all blobs in a virtual directory, refer to the virtual directory name instead of the blob name, and then append --recursive=true to the command.

Example

azcopy set-properties 'https://mystorageaccount.blob.core.windows.net/mycontainer/myvirtualdirectory' --blob-tags=mytag1=mytag1value;mytag2=mytag2value

Next steps

Find more examples in these articles:

See these articles to configure settings, optimize performance, and troubleshoot issues: