Skip to content

Commit bbe3798

Browse files
edits
1 parent d57b132 commit bbe3798

13 files changed

+72
-30
lines changed

articles/storage/blobs/storage-blob-container-create-go.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ ms.custom: devx-track-go, devguide-go
1717

1818
[!INCLUDE [storage-dev-guide-selector-create-container](../../../includes/storage-dev-guides/storage-dev-guide-selector-create-container.md)]
1919

20-
Blobs in Azure Storage are organized into containers. Before you can upload a blob, you must first create a container. This article shows how to create containers with the [Azure Storage client module for Go](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#section-readme).
20+
This article shows how to create containers with the [Azure Storage client module for Go](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#section-readme). Blobs in Azure Storage are organized into containers. Before you can upload a blob, you must first create a container.
2121

2222
[!INCLUDE [storage-dev-guide-prereqs-go](../../../includes/storage-dev-guides/storage-dev-guide-prereqs-go.md)]
2323

2424
## Set up your environment
2525

2626
[!INCLUDE [storage-dev-guide-project-setup-go](../../../includes/storage-dev-guides/storage-dev-guide-project-setup-go.md)]
2727

28-
### Authorization
28+
#### Authorization
2929

30-
The authorization mechanism must have the necessary permissions to create a container.For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Contributor** or higher. To learn more, see the authorization guidance for [Create Container (REST API)](/rest/api/storageservices/create-container#authorization).
30+
The authorization mechanism must have the necessary permissions to create a container. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Contributor** or higher. To learn more, see the authorization guidance for [Create Container (REST API)](/rest/api/storageservices/create-container#authorization).
3131

3232
[!INCLUDE [storage-dev-guide-about-container-naming](../../../includes/storage-dev-guides/storage-dev-guide-about-container-naming.md)]
3333

@@ -55,6 +55,8 @@ The following example creates the container if it doesn't already exist in the s
5555

5656
:::code language="go" source="~/blob-devguide-go/cmd/create-container/create_container.go" id="snippet_create_root_container":::
5757

58+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
59+
5860
## Resources
5961

6062
To learn more about creating a container using the Azure Blob Storage client module for Go, see the following resources.

articles/storage/blobs/storage-blob-container-delete-go.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This article shows how to delete containers with the [Azure Storage client modul
2525

2626
[!INCLUDE [storage-dev-guide-project-setup-go](../../../includes/storage-dev-guides/storage-dev-guide-project-setup-go.md)]
2727

28-
### Authorization
28+
#### Authorization
2929

3030
The authorization mechanism must have the necessary permissions to delete or restore a container. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Contributor** or higher. To learn more, see the authorization guidance for [Delete Container (REST API)](/rest/api/storageservices/delete-container#authorization) and [Restore Container (REST API)](/rest/api/storageservices/restore-container#authorization).
3131

@@ -51,6 +51,8 @@ The following example lists containers, including soft-deleted containers, and i
5151

5252
:::code language="go" source="~/blob-devguide-go/cmd/delete-container/delete_container.go" id="snippet_restore_container":::
5353

54+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
55+
5456
## Resources
5557

5658
To learn more about deleting a container using the Azure Blob Storage client module for Go, see the following resources.

articles/storage/blobs/storage-blob-container-properties-metadata-go.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Blob containers support system properties and user-defined metadata, in addition
2525

2626
[!INCLUDE [storage-dev-guide-project-setup-go](../../../includes/storage-dev-guides/storage-dev-guide-project-setup-go.md)]
2727

28-
### Authorization
28+
#### Authorization
2929

3030
The authorization mechanism must have the necessary permissions to work with container properties or metadata. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Reader** or higher for the *get* operations, and **Storage Blob Data Contributor** or higher for the *set* operations. To learn more, see the authorization guidance for [Get Container Properties](/rest/api/storageservices/get-container-properties#authorization), [Set Container Metadata](/rest/api/storageservices/set-container-metadata#authorization), or [Get Container Metadata](/rest/api/storageservices/get-container-metadata#authorization).
3131

@@ -67,6 +67,8 @@ Metadata is included in the response from `GetProperties`. The following example
6767

6868
:::code language="go" source="~/blob-devguide-go/cmd/container-properties-metadata/container_properties_metadata.go" id="snippet_get_container_metadata":::
6969

70+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
71+
7072
## Resources
7173

7274
To learn more about setting and retrieving container properties and metadata using the Azure Blob Storage client module for Go, see the following resources.

articles/storage/blobs/storage-blob-containers-list-go.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ When you list the containers in an Azure Storage account from your code, you can
2525

2626
[!INCLUDE [storage-dev-guide-project-setup-go](../../../includes/storage-dev-guides/storage-dev-guide-project-setup-go.md)]
2727

28-
### Authorization
28+
#### Authorization
2929

3030
The authorization mechanism must have the necessary permissions to list blob containers. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Contributor** or higher. To learn more, see the authorization guidance for [List Containers](/rest/api/storageservices/list-containers2#authorization).
3131

@@ -71,14 +71,16 @@ You can also specify a limit for the number of results per page. This example pa
7171

7272
:::code language="go" source="~/blob-devguide-go/cmd/list-containers/list_containers.go" id="snippet_list_containers_pages":::
7373

74+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
75+
7476
## Resources
7577

7678
To learn more about listing containers using the Azure Blob Storage client module for Go, see the following resources.
7779

7880
### Code samples
7981

8082
- View [code samples](https://github.com/Azure-Samples/blob-storage-devguide-go/cmd/list-containers/list_containers.go) from this article (GitHub)
81-
-
83+
8284
### REST API operations
8385

8486
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 listing containers use the following REST API operation:

articles/storage/blobs/storage-blob-delete-go.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This article shows how to delete blobs using the [Azure Storage client module fo
2525

2626
[!INCLUDE [storage-dev-guide-project-setup-go](../../../includes/storage-dev-guides/storage-dev-guide-project-setup-go.md)]
2727

28-
### Authorization
28+
#### Authorization
2929

3030
The authorization mechanism must have the necessary permissions to delete a blob, or to restore a soft-deleted blob. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Contributor** or higher. To learn more, see the authorization guidance for [Delete Blob](/rest/api/storageservices/delete-blob#authorization) and [Undelete Blob](/rest/api/storageservices/undelete-blob#authorization).
3131

@@ -43,7 +43,7 @@ If the blob has any associated snapshots, you must delete all of its snapshots t
4343

4444
:::code language="go" source="~/blob-devguide-go/cmd/delete_blob/delete_blob.go" id="snippet_delete_blob_snapshots":::
4545

46-
To delete *only* the snapshots and not the blob itself, you can pass the parameter `delete_snapshots="only"`.
46+
To delete *only* the snapshots and not the blob itself, you can pass the value `DeleteSnapshotsOptionTypeOnly` to the `DeleteSnapshots` parameter.
4747

4848
## Restore a deleted blob
4949

@@ -76,6 +76,8 @@ The following code example identifies a version of a deleted blob, and restores
7676

7777
:::code language="go" source="~/blob-devguide-go/cmd/delete_blob/delete_blob.go" id="snippet_restore_blob_version":::
7878

79+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
80+
7981
## Resources
8082

8183
To learn more about how to delete blobs and restore deleted blobs using the Azure Blob Storage client module for Go, see the following resources.

articles/storage/blobs/storage-blob-download-go.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ ms.custom: devx-track-go, devguide-go
1717

1818
[!INCLUDE [storage-dev-guide-selector-download](../../../includes/storage-dev-guides/storage-dev-guide-selector-download.md)]
1919

20-
This article shows how to download a blob using the [Azure Storage client module for Go](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#section-readme). You can download blob data to various destinations, including a local file path, stream, or text string. You can also open a blob stream and read from it.
20+
This article shows how to download a blob using the [Azure Storage client module for Go](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#section-readme). You can download blob data to various destinations, including a local file path, stream, or text string.
2121

2222
[!INCLUDE [storage-dev-guide-prereqs-go](../../../includes/storage-dev-guides/storage-dev-guide-prereqs-go.md)]
2323

2424
## Set up your environment
2525

2626
[!INCLUDE [storage-dev-guide-project-setup-go](../../../includes/storage-dev-guides/storage-dev-guide-project-setup-go.md)]
2727

28-
### Authorization
28+
#### Authorization
2929

30-
The authorization mechanism must have the necessary permissions to perform a download operation. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Contributor** or higher. To learn more, see the authorization guidance for [Get Blob](/rest/api/storageservices/get-blob#authorization).
30+
The authorization mechanism must have the necessary permissions to perform a download operation. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Reader** or higher. To learn more, see the authorization guidance for [Get Blob](/rest/api/storageservices/get-blob#authorization).
3131

3232
## Download a blob
3333

@@ -49,6 +49,8 @@ The following example downloads a blob to a stream, and reads from the stream by
4949

5050
:::code language="go" source="~/blob-devguide-go/cmd/download-blob/download_blob.go" id="snippet_download_blob_stream":::
5151

52+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
53+
5254
## Resources
5355

5456
To learn more about how to download blobs using the Azure Blob Storage client module for Go, see the following resources.

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ This article shows you how to connect to Azure Blob Storage by using the Azure B
3131

3232
This section walks you through preparing a project to work with the Azure Blob Storage client module for Go.
3333

34-
From your project directory, install packages for the Azure Blob Storage and Azure Identity client libraries using the `go get` command. The **azidentity** package is needed for passwordless connections to Azure services.
34+
From your GOPATH, install the [azblob](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/) module using the following command:
3535

3636
```console
37-
go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob github.com/Azure/azure-sdk-for-go/sdk/azidentity
37+
go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
3838
```
3939

40-
Then open your code file and add the necessary import statements. In this example, we add the following to our *.go* file:
40+
To authenticate with Microsoft Entra ID (recommended), install the [`azidentity`](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity) module using the following command:
41+
42+
```console
43+
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
44+
```
45+
46+
Then open your code file and add the necessary import paths. In this example, we add the following to our *.go* file:
4147

4248
```go
4349
import (
@@ -46,7 +52,7 @@ import (
4652
)
4753
```
4854

49-
Blob client library information:
55+
Blob client module information:
5056

5157
- [azblob](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#section_documentation): Contains the methods that you can use to operate on the service, containers, and blobs.
5258

@@ -57,7 +63,7 @@ To connect an application to Blob Storage, create a client object using [azblob.
5763

5864
To learn more about creating and managing client objects, including best practices, see [Create and manage client objects that interact with data resources](storage-blob-client-management.md).
5965

60-
You can authorize a client object using a Microsoft Entra authorization token, an account access key, or a shared access signature (SAS).
66+
You can authorize a client object using a Microsoft Entra authorization token (recommended), an account access key, or a shared access signature (SAS).
6167

6268
<a name='azure-ad'></a>
6369

@@ -81,13 +87,15 @@ To use a shared access signature (SAS) token, append the token to the account UR
8187

8288
:::code language="go" source="~/blob-devguide-go/cmd/client-auth/client_auth.go" id="snippet_get_service_client_SAS":::
8389

90+
> [!NOTE]
91+
> A user delegation SAS offers superior security to a SAS that is signed with the storage account key. Microsoft recommends using a user delegation SAS when possible. For more information, see [Grant limited access to data with shared access signatures (SAS)](../articles/storage/common/storage-sas-overview.md).
92+
8493
## [Account key](#tab/account-key)
8594

8695
To use a storage account shared key, provide the key as a string and initialize a client object using [azblob.NewClientWithSharedKeyCredential](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#NewClientWithSharedKeyCredential).
8796

8897
:::code language="go" source="~/blob-devguide-go/cmd/client-auth/client_auth.go" id="snippet_get_service_client_shared_key":::
8998

90-
9199
You can also create a client object using a connection string.
92100

93101
:::code language="go" source="~/blob-devguide-go/cmd/client-auth/client_auth.go" id="Snippet_get_service_client_connection_string":::
@@ -103,7 +111,7 @@ For information about how to obtain account keys and best practice guidelines fo
103111

104112
As you build applications to work with data resources in Azure Blob Storage, your code primarily interacts with three resource types: storage accounts, containers, and blobs. To learn more about these resource types, how they relate to one another, and how apps interact with resources, see [Understand how apps interact with Blob Storage data resources](storage-blob-object-model.md).
105113

106-
The following guides show you how to work with data resources and perform specific actions using the Azure Storage client library for Go:
114+
The following guides show you how to work with data resources and perform specific actions using the Azure Blob Storage client module for Go:
107115

108116
| Guide | Description |
109117
|--|---|
@@ -116,3 +124,5 @@ The following guides show you how to work with data resources and perform specif
116124
| [List blobs](storage-blobs-list-go.md) | List blobs in different ways. |
117125
| [Delete and restore blobs](storage-blob-delete-go.md) | Delete blobs, and if soft-delete is enabled, restore deleted blobs. |
118126
| [Manage properties and metadata (blobs)](storage-blob-properties-metadata-go.md) | Manage container properties and metadata. |
127+
128+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]

articles/storage/blobs/storage-blob-properties-metadata-go.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ In addition to the data they contain, blobs support system properties and user-d
2525

2626
[!INCLUDE [storage-dev-guide-project-setup-go](../../../includes/storage-dev-guides/storage-dev-guide-project-setup-go.md)]
2727

28-
### Authorization
28+
#### Authorization
2929

3030
The authorization mechanism must have the necessary permissions to work with container properties or metadata. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Reader** or higher for the *get* operations, and **Storage Blob Data Contributor** or higher for the *set* operations. To learn more, see the authorization guidance for [Set Blob Properties](/rest/api/storageservices/set-blob-properties#authorization), [Get Blob Properties](/rest/api/storageservices/get-blob-properties#authorization), [Set Blob Metadata](/rest/api/storageservices/set-blob-metadata#authorization), or [Get Blob Metadata](/rest/api/storageservices/get-blob-metadata#authorization).
3131

@@ -78,6 +78,8 @@ The following code example reads metadata on a blob and prints each key/value pa
7878

7979
:::code language="go" source="~/blob-devguide-go/cmd/blob-properties-metadata/blob_properties_metadata.go" id="snippet_get_blob_metadata":::
8080

81+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
82+
8183
## Resources
8284

8385
To learn more about how to manage system properties and user-defined metadata using the Azure Blob Storage client module for Go, see the following resources.

articles/storage/blobs/storage-blob-upload-go.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This article shows how to upload a blob using the [Azure Storage client module f
2525

2626
[!INCLUDE [storage-dev-guide-project-setup-go](../../../includes/storage-dev-guides/storage-dev-guide-project-setup-go.md)]
2727

28-
### Authorization
28+
#### Authorization
2929

3030
The authorization mechanism must have the necessary permissions to upload a blob. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Contributor** or higher. To learn more, see the authorization guidance for [Put Blob](/rest/api/storageservices/put-blob#authorization) and [Put Block](/rest/api/storageservices/put-block#authorization).
3131

@@ -80,6 +80,8 @@ The following code example shows how to specify data transfer options using the
8080

8181
:::code language="go" source="~/blob-devguide-go/cmd/upload-blob/upload_blob.go" id="snippet_upload_blob_transfer_options":::
8282

83+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
84+
8385
## Resources
8486

8587
To learn more about uploading blobs using the Azure Blob Storage client module for Go, see the following resources.

articles/storage/blobs/storage-blobs-list-go.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This article shows how to list blobs using the [Azure Storage client module for
2525

2626
[!INCLUDE [storage-dev-guide-project-setup-go](../../../includes/storage-dev-guides/storage-dev-guide-project-setup-go.md)]
2727

28-
### Authorization
28+
#### Authorization
2929

3030
The authorization mechanism must have the necessary permissions to upload a blob. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Reader** or higher. To learn more, see the authorization guidance for [List Blobs](/rest/api/storageservices/list-blobs#authorization).
3131

@@ -63,6 +63,9 @@ To organize blobs into virtual directories, use a delimiter character in the blo
6363

6464
If you name your blobs using a delimiter, then you can choose to list blobs hierarchically. For a hierarchical listing operation, Azure Storage returns any virtual directories and blobs beneath the parent object. You can call the listing operation recursively to traverse the hierarchy, similar to how you would traverse a classic file system programmatically.
6565

66+
> [!NOTE]
67+
> Blob snapshots cannot be listed in a hierarchical listing operation.
68+
6669
## Use a flat listing
6770

6871
By default, a listing operation returns blobs in a flat listing. In a flat listing, blobs aren't organized by virtual directory.
@@ -124,8 +127,7 @@ Blob: folderA/folderB/file2.txt
124127
Blob: folderA/folderB/file3.txt
125128
```
126129

127-
> [!NOTE]
128-
> Blob snapshots cannot be listed in a hierarchical listing operation.
130+
[!INCLUDE [storage-dev-guide-code-samples-note-go](../../../includes/storage-dev-guides/storage-dev-guide-code-samples-note-go.md)]
129131

130132
## Resources
131133

0 commit comments

Comments
 (0)