Skip to content

Commit 7ec322d

Browse files
authored
Merge pull request #279317 from pauljewellmsft/index-tags-go
Add blob index tag article for Go
2 parents 6896647 + 51a77fc commit 7ec322d

File tree

3 files changed

+104
-1
lines changed

3 files changed

+104
-1
lines changed

articles/storage/blobs/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,8 @@ items:
989989
href: storage-blobs-list-go.md
990990
- name: Delete and restore blobs
991991
href: storage-blob-delete-go.md
992+
- name: Find blobs using tags
993+
href: storage-blob-tags-go.md
992994
- name: Manage blob properties and metadata
993995
href: storage-blob-properties-metadata-go.md
994996
- name: Client library configuration options

articles/storage/blobs/storage-blob-go-get-started.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.author: pauljewell
88

99
ms.service: azure-blob-storage
1010
ms.topic: how-to
11-
ms.date: 05/22/2024
11+
ms.date: 06/26/2024
1212
ms.devlang: golang
1313
ms.custom: devx-track-go, devguide-go
1414
---
@@ -123,6 +123,7 @@ The following guides show you how to work with data resources and perform specif
123123
| [Download blobs](storage-blob-download-go.md) | Download blobs by using strings, streams, and file paths. |
124124
| [List blobs](storage-blobs-list-go.md) | List blobs in different ways. |
125125
| [Delete and restore blobs](storage-blob-delete-go.md) | Delete blobs, and if soft-delete is enabled, restore deleted blobs. |
126+
| [Find blobs using tags](storage-blob-tags-go.md) | Set and retrieve tags, and use tags to find blobs. |
126127
| [Manage properties and metadata (blobs)](storage-blob-properties-metadata-go.md) | Manage container properties and metadata. |
127128

128129
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: Use blob index tags to manage and find data with Go
3+
titleSuffix: Azure Storage
4+
description: Learn how to categorize, manage, and query for blob objects by using the Go client module.
5+
services: storage
6+
author: pauljewellmsft
7+
8+
ms.author: pauljewell
9+
ms.date: 06/26/2024
10+
ms.service: azure-blob-storage
11+
ms.topic: how-to
12+
ms.devlang: golang
13+
ms.custom: devx-track-go, devguide-go
14+
---
15+
16+
# Use blob index tags to manage and find data with Go
17+
18+
[!INCLUDE [storage-dev-guide-selector-index-tags](../../../includes/storage-dev-guides/storage-dev-guide-selector-index-tags.md)]
19+
20+
This article shows how to use blob index tags to manage and find data using the [Azure Storage client module for Go](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#section-readme).
21+
22+
[!INCLUDE [storage-dev-guide-prereqs-go](../../../includes/storage-dev-guides/storage-dev-guide-prereqs-go.md)]
23+
24+
## Set up your environment
25+
26+
[!INCLUDE [storage-dev-guide-project-setup-go](../../../includes/storage-dev-guides/storage-dev-guide-project-setup-go.md)]
27+
28+
#### Authorization
29+
30+
The authorization mechanism must have the necessary permissions to work with blob index tags. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Owner** or higher. To learn more, see the authorization guidance for [Get Blob Tags](/rest/api/storageservices/get-blob-tags#authorization), [Set Blob Tags](/rest/api/storageservices/set-blob-tags#authorization), or [Find Blobs by Tags](/rest/api/storageservices/find-blobs-by-tags#authorization).
31+
32+
[!INCLUDE [storage-dev-guide-about-blob-tags](../../../includes/storage-dev-guides/storage-dev-guide-about-blob-tags.md)]
33+
34+
## Set tags
35+
36+
[!INCLUDE [storage-dev-guide-auth-set-blob-tags](../../../includes/storage-dev-guides/storage-dev-guide-auth-set-blob-tags.md)]
37+
38+
You can set tags by using the following method:
39+
40+
- [SetTags](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob#Client.SetTags)
41+
42+
The tags specified in this method replace any existing tags. If existing values must be preserved, they must be downloaded and included in the call to this method. The following example shows how to set tags:
43+
44+
:::code language="go" source="~/blob-devguide-go/cmd/blob-index-tags/blob_index_tags.go" id="snippet_set_blob_tags":::
45+
46+
You can remove all tags by calling `SetTags` with no tags, as shown in the following example:
47+
48+
:::code language="go" source="~/blob-devguide-go/cmd/blob-index-tags/blob_index_tags.go" id="snippet_clear_blob_tags":::
49+
50+
## Get tags
51+
52+
[!INCLUDE [storage-dev-guide-auth-get-blob-tags](../../../includes/storage-dev-guides/storage-dev-guide-auth-get-blob-tags.md)]
53+
54+
You can get tags by using the following method:
55+
56+
- [GetTags](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob#Client.GetTags)
57+
58+
The following example shows how to retrieve and iterate over the blob's tags:
59+
60+
:::code language="go" source="~/blob-devguide-go/cmd/blob-index-tags/blob_index_tags.go" id="snippet_get_blob_tags":::
61+
62+
## Filter and find data with blob index tags
63+
64+
[!INCLUDE [storage-dev-guide-auth-filter-blob-tags](../../../includes/storage-dev-guides/storage-dev-guide-auth-filter-blob-tags.md)]
65+
66+
> [!NOTE]
67+
> 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](storage-manage-find-blobs.md#conditions-and-known-issues).
68+
69+
You can filter blob data based on index tags by using the following method:
70+
71+
- [FilterBlobs](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/[email protected]/container#Client.FilterBlobs)
72+
73+
The following example finds and lists all blobs tagged as an image:
74+
75+
:::code language="go" source="~/blob-devguide-go/cmd/blob-index-tags/blob_index_tags.go" id="snippet_find_blobs_by_tags":::
76+
77+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
78+
79+
## Resources
80+
81+
To learn more about how to use index tags to manage and find data using the Azure Blob Storage client library for Go, see the following resources.
82+
83+
### Code samples
84+
85+
- View [code samples](https://github.com/Azure-Samples/blob-storage-devguide-go/blob/main/cmd/blob-index-tags/blob-index-tags.go) from this article (GitHub)
86+
87+
### REST API operations
88+
89+
The Azure SDK for Go contains libraries that build on top of the Azure REST API, allowing you to interact with REST API operations through familiar Go paradigms. The client library methods for managing and using blob index tags use the following REST API operations:
90+
91+
- [Get Blob Tags](/rest/api/storageservices/get-blob-tags) (REST API)
92+
- [Set Blob Tags](/rest/api/storageservices/set-blob-tags) (REST API)
93+
- [Find Blobs by Tags](/rest/api/storageservices/find-blobs-by-tags) (REST API)
94+
95+
[!INCLUDE [storage-dev-guide-resources-go](../../../includes/storage-dev-guides/storage-dev-guide-resources-go.md)]
96+
97+
### See also
98+
99+
- [Manage and find Azure Blob data with blob index tags](storage-manage-find-blobs.md)
100+
- [Use blob index tags to manage and find data on Azure Blob Storage](storage-blob-index-how-to.md)

0 commit comments

Comments
 (0)