Skip to content

Latest commit

 

History

History
96 lines (58 loc) · 5.2 KB

storage-blob-tags-java.md

File metadata and controls

96 lines (58 loc) · 5.2 KB
title titleSuffix description services author ms.author ms.date ms.service ms.topic ms.devlang ms.custom
Use blob index tags to manage and find data with Java
Azure Storage
Learn how to categorize, manage, and query for blob objects by using the Java client library.
storage
pauljewellmsft
pauljewell
02/02/2024
azure-blob-storage
how-to
java
devx-track-java, devguide-java, devx-track-extended-java

Use blob index tags to manage and find data with Java

[!INCLUDE storage-dev-guide-selector-index-tags]

This article shows how to use blob index tags to manage and find data using the Azure Storage client library for Java.

Prerequisites

[!INCLUDE storage-dev-guide-about-blob-tags]

Set tags

[!INCLUDE storage-dev-guide-auth-set-blob-tags]

You can set tags by using the following method:

The specified tags in this method will replace existing tags. If old values must be preserved, they must be downloaded and included in the call to this method. The following example shows how to set tags:

:::code language="java" source="~/azure-storage-snippets/blobs/howto/Java/blob-devguide/blob-devguide-blobs/src/main/java/com/blobs/devguide/blobs/BlobPropertiesMetadataTags.java" id="Snippet_SetBLobTags":::

You can delete all tags by passing an empty Map object into the setTags method:

:::code language="java" source="~/azure-storage-snippets/blobs/howto/Java/blob-devguide/blob-devguide-blobs/src/main/java/com/blobs/devguide/blobs/BlobPropertiesMetadataTags.java" id="Snippet_ClearBLobTags":::

Get tags

[!INCLUDE storage-dev-guide-auth-get-blob-tags]

You can get tags by using the following method:

The following example shows how to retrieve and iterate over the blob's tags:

:::code language="java" source="~/azure-storage-snippets/blobs/howto/Java/blob-devguide/blob-devguide-blobs/src/main/java/com/blobs/devguide/blobs/BlobPropertiesMetadataTags.java" id="Snippet_GetBLobTags":::

Filter and find data with blob index tags

[!INCLUDE storage-dev-guide-auth-filter-blob-tags]

Note

You can't use index tags to retrieve previous versions. Tags for previous versions aren't passed to the blob index engine. For more information, see Conditions and known issues.

You can find data by using the following method:

The following example finds all blobs tagged as an image:

:::code language="java" source="~/azure-storage-snippets/blobs/howto/Java/blob-devguide/blob-devguide-blobs/src/main/java/com/blobs/devguide/blobs/BlobPropertiesMetadataTags.java" id="Snippet_FindBlobsByTag":::

Resources

To learn more about how to use index tags to manage and find data using the Azure Blob Storage client library for Java, see the following resources.

REST API operations

The Azure SDK for Java contains libraries that build on top of the Azure REST API, allowing you to interact with REST API operations through familiar Java paradigms. The client library methods for managing and using blob index tags use the following REST API operations:

Code samples

[!INCLUDE storage-dev-guide-resources-java]

See also