You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/storage/blobs/storage-quickstart-blobs-go.md
+18-11Lines changed: 18 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,8 +22,15 @@ Get started with the Azure Blob Storage client library for Go to manage blobs an
22
22
23
23
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
24
24
- Azure storage account - [create a storage account](../common/storage-account-create.md)
25
-
-[Go 1.18 or above](https://go.dev/dl/)
26
-
-[Azure Blob Storage SDK for Go](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/), using the following command:
25
+
-[Go 1.18+](https://go.dev/dl/)
26
+
27
+
## Setting up
28
+
29
+
This section walks you through preparing a project to work with the Azure Blob Storage client library for Go.
30
+
31
+
### Install the packages
32
+
33
+
- To work with blob and container resources in a storage account, install the [azblob](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/) package using the following command:
27
34
28
35
```
29
36
go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
@@ -34,7 +41,7 @@ Get started with the Azure Blob Storage client library for Go to manage blobs an
34
41
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
35
42
```
36
43
37
-
## Download the sample application
44
+
### Download the sample application
38
45
39
46
The [sample application](https://github.com/Azure-Samples/storage-blobs-go-quickstart.git) used in this quickstart is a basic Go application.
@@ -56,11 +63,11 @@ The order and locations in which `DefaultAzureCredential` looks for credentials
56
63
57
64
For example, your app can authenticate using your Azure CLI sign-in credentials with when developing locally. Your app can then use a [managed identity](../../active-directory/managed-identities-azure-resources/overview.md) once it has been deployed to Azure. No code changes are required for this transition.
####Sign-in and connect your app code to Azure using DefaultAzureCredential
70
+
### Sign-in and connect your app code to Azure using DefaultAzureCredential
64
71
65
72
You can authorize access to data in your storage account using the following steps:
66
73
@@ -76,7 +83,7 @@ You can authorize access to data in your storage account using the following ste
76
83
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
77
84
```
78
85
79
-
Azure CLI authentication isn't recommended for applications running in Azure. When deployed to Azure, this same code can be used to authorize requests to Azure Storage from an application running in Azure. However, you'll need to enable managed identity on your app in Azure. Then configure your storage account to allow that managed identity to connect. For detailed instructions on configuring this connection between Azure services, see the [Auth from Azure-hosted apps](/developer/go/azure-sdk-authentication-managed-identity) tutorial.
86
+
Azure CLI authentication isn't recommended for applications running in Azure. When deployed to Azure, this same code can be used to authorize requests to Azure Storage from an application running in Azure. However, you need to enable managed identity on your app in Azure and configure your storage account to allow that managed identity to connect. For detailed instructions on configuring this connection between Azure services, see the [Auth from Azure-hosted apps](/developer/go/azure-sdk-authentication-managed-identity) tutorial.
80
87
81
88
To learn more about different authentication methods, check out [Azure authentication with the Azure SDK for Go](/azure/developer/go/azure-sdk-authentication).
82
89
@@ -150,10 +157,10 @@ handleError(err)
150
157
```
151
158
152
159
### Create a container
153
-
The code sample creates a new container resource in the storage account. If a container with the same name already exists, a `ResourceExistsError`will be raised.
160
+
The code sample creates a new container resource in the storage account. If a container with the same name already exists, a `ResourceExistsError`is raised.
154
161
155
162
> [!IMPORTANT]
156
-
> Container names must be lowercase. See [Naming and Referencing Containers, Blobs, and Metadata](/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata) for more information about container and blob names.
163
+
> Container names must be lowercase. To learn more about naming requirements for containers and blobs, see [Naming and Referencing Containers, Blobs, and Metadata](/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata).
157
164
158
165
The following code example creates a new container called *quickstart-sample-container* in the storage account:
159
166
@@ -207,7 +214,7 @@ for pager.More() {
207
214
208
215
### Download the blob
209
216
210
-
The code sample downloads a blob using the [DownloadStream](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#Client.DownloadStream) method, and creates a retry reader for reading data. If a connection fails while reading, the retry reader will make other requests to re-establish a connection and continue reading. You can specify retry reader options using the [RetryReaderOptions](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob#RetryReaderOptions) struct.
217
+
The code sample downloads a blob using the [DownloadStream](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#Client.DownloadStream) method, and creates a retry reader for reading data. If a connection fails while reading, the retry reader makes other requests to re-establish a connection and continue reading. You can specify retry reader options using the [RetryReaderOptions](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob#RetryReaderOptions) struct.
211
218
212
219
The following code example downloads a blob and writes the contents to the console:
213
220
@@ -255,5 +262,5 @@ To see Blob storage sample apps, continue to:
255
262
> [!div class="nextstepaction"]
256
263
> [Azure Blob Storage library for Go samples](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#example-package)
257
264
258
-
- To learn more, see the [Azure Blob Storage client libraries for Go](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/storage/azblob).
265
+
- To learn more, see the [Azure Blob Storage client library for Go](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/storage/azblob).
259
266
- For tutorials, samples, quickstarts, and other documentation, visit [Azure for Go Developers](/azure/developer/go/overview).
0 commit comments