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 |
[!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.
- This article assumes you already have a project set up to work with the Azure Blob Storage client library for Java. To learn about setting up your project, including package installation, adding
import
directives, and creating an authorized client object, see Get Started with Azure Storage and Java. - The authorization mechanism must have permissions to work with blob index tags. To learn more, see the authorization guidance for the following REST API operations:
[!INCLUDE storage-dev-guide-about-blob-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":::
[!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":::
[!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":::
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.
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:
- Get Blob Tags (REST API)
- Set Blob Tags (REST API)
- Find Blobs by Tags (REST API)
[!INCLUDE storage-dev-guide-resources-java]