Skip to content

How to use blob index tag feature in AzCopy

Mohit Sharma edited this page Apr 13, 2021 · 2 revisions

Blob index tags categorize data in your storage account using key-value tag attributes. These tags are automatically indexed and exposed as a searchable multi-dimensional index to easily find data. This article shows you how to set, get, and find data using blob index tags.

Set Tags on the blobs through AzCopy

As mentioned above, tags are key-value pair. So, to set tags

  • key = "bla bla", value = "foo" and
  • key = "bla bla 2", value = "bar"

you can use the following syntax :

azcopy cp "/source/path" "https://[account].blob.core.windows.net/[container]/[path/to/directory]?[SAS]" --blob-tags="bla%20bla=foo&bla%20bla%202=bar"

Preserve blob tags from the source through AzCopy

We also support s2s-preserve-blob-tags flags when use wishes to preserve blob tags from source to destination. Needless to say that in this scenario source must always be a blob storage. To copy blobs from one blob storage to another and preserve the tags from source, use the following syntax :

azcopy cp "https://[account].blob.core.windows.net/[source_container]/[path/to/directory]?[SAS]" "https://[account].blob.core.windows.net/[destination_container]/[path/to/directory]?[SAS]" --s2s-preserve-blob-tags=true

POINTS TO NOTE WHILE SETTING TAGS

  1. Please note that tags are a property of blobs only. So when setting blobs, destination must always be a blob store.
  2. Keys and values are URL encoded and the key-value pairs are separated by an ampersand('&')
  3. While setting tags on the blobs, there are additional permissions('t' for tags) in SAS without which the service will give authorization error back.
  4. Source can be a file or a folder or a remote source. But when source path points to a local folder or remote source containing multiple files, all the blobs thus copied will have the same tags specified by the command.
  5. When performing service to service copy, we do not preserve blob tags at source location unless specified explicitly. We set tags only when specified by the user explicitly through the command.
  6. For more information on tags, please refer to Blob Index Tags, Set Tags API, Get Tags API, and Find Blobs by Tags API
  7. AzCopy sets tags during upload/transfer itself but if the size of tags is more than 2000B, it is required to make additional SetTags API call which will incur extra charges. Please refer to official documentation for more information.