@@ -7,7 +7,7 @@ author: pauljewellmsft
7
7
8
8
ms.service : azure-blob-storage
9
9
ms.topic : how-to
10
- ms.date : 08/05/2024
10
+ ms.date : 01/27/2025
11
11
ms.author : pauljewell
12
12
ms.devlang : csharp
13
13
# ms.devlang: csharp, java, javascript, python
@@ -37,7 +37,8 @@ The following table lists the different client classes for each language:
37
37
| .NET | [ Azure.Storage.Blobs] ( /dotnet/api/azure.storage.blobs ) <br >[ Azure.Storage.Blobs.Models] ( /dotnet/api/azure.storage.blobs.models ) <br >[ Azure.Storage.Blobs.Specialized] ( /dotnet/api/azure.storage.blobs.specialized ) | [ BlobServiceClient] ( /dotnet/api/azure.storage.blobs.blobserviceclient ) | [ BlobContainerClient] ( /dotnet/api/azure.storage.blobs.blobcontainerclient ) | [ BlobClient] ( /dotnet/api/azure.storage.blobs.blobclient ) <br >[ BlockBlobClient] ( /dotnet/api/azure.storage.blobs.specialized.blockblobclient ) <br >[ AppendBlobClient] ( /dotnet/api/azure.storage.blobs.specialized.appendblobclient ) <br >[ PageBlobClient] ( /dotnet/api/azure.storage.blobs.specialized.pageblobclient ) |
38
38
| Java | [com.azure.storage.blob](/java/api/com.azure.storage.blob)<br>[com.azure.storage.blob.models](/java/api/com.azure.storage.blob.models)<br>[com.azure.storage.blob.specialized](/java/api/com.azure.storage.blob.specialized) | [BlobServiceClient](/java/api/com.azure.storage.blob.blobserviceclient)<br>[BlobServiceAsyncClient](/java/api/com.azure.storage.blob.blobserviceasyncclient)<br>[BlobServiceClientBuilder](/java/api/com.azure.storage.blob.blobserviceclientbuilder) | [BlobContainerClient](/java/api/com.azure.storage.blob.blobcontainerclient)<br>[BlobContainerAsyncClient](/java/api/com.azure.storage.blob.blobcontainerasyncclient)<br>[BlobContainerClientBuilder](/java/api/com.azure.storage.blob.blobcontainerclientbuilder) | [BlobClient](/java/api/com.azure.storage.blob.blobclient)<br>[BlobAsyncClient](/java/api/com.azure.storage.blob.blobasyncclient)<br>[BlobClientBuilder](/java/api/com.azure.storage.blob.blobclientbuilder)<br>[BlockBlobClient](/java/api/com.azure.storage.blob.specialized.blockblobclient)<br>[AppendBlobClient](/java/api/com.azure.storage.blob.specialized.appendblobclient)<br>[PageBlobClient](/java/api/com.azure.storage.blob.specialized.pageblobclient) |
39
39
| JavaScript | [ @azure/storage-blob ] ( /javascript/api/overview/azure/storage-blob-readme ) | [ BlobServiceClient] ( /javascript/api/@azure/storage-blob/blobserviceclient ) | [ ContainerClient] ( /javascript/api/@azure/storage-blob/containerclient ) | [ BlobClient] ( /javascript/api/@azure/storage-blob/blobclient ) <br >[ BlockBlobClient] ( /javascript/api/@azure/storage-blob/blockblobclient ) <br >[ AppendBlobClient] ( /javascript/api/@azure/storage-blob/appendblobclient ) <br >[ PageBlobClient] ( /javascript/api/@azure/storage-blob/pageblobclient ) |
40
- | Python | [ azure.storage.blob] ( /python/api/azure-storage-blob/azure.storage.blob ) | [ BlobServiceClient] ( /python/api/azure-storage-blob/azure.storage.blob.blobserviceclient ) | [ ContainerClient] ( /python/api/azure-storage-blob/azure.storage.blob.containerclient ) | [ BlobClient] ( /python/api/azure-storage-blob/azure.storage.blob.blobclient ) <sup >1 |
40
+ | Python | [ azure.storage.blob] ( /python/api/azure-storage-blob/azure.storage.blob ) | [ BlobServiceClient] ( /python/api/azure-storage-blob/azure.storage.blob.blobserviceclient ) | [ ContainerClient] ( /python/api/azure-storage-blob/azure.storage.blob.containerclient ) | [ BlobClient] ( /python/api/azure-storage-blob/azure.storage.blob.blobclient ) <sup >1</sup > |
41
+ | Go | [ azblob] ( https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob ) | [ azblob.Client] ( https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob#Client ) | [ container.Client] ( https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container#Client ) | [ blob.Client] ( https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob#Client ) <br >[ blockblob.Client] ( https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob#Client ) <br >[ appendblob.Client] ( https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/appendblob#Client ) <br >[ pageblob.Client] ( https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/pageblob#Client ) |
41
42
42
43
<sup >1</sup > For Python, ` BlobClient ` includes methods for specialized blob types.
43
44
@@ -155,6 +156,39 @@ def get_blob_service_client(self, account_name):
155
156
return blob_service_client
156
157
```
157
158
159
+ ## [ Go] ( #tab/go )
160
+
161
+ Add the following ` import ` statements:
162
+
163
+ ``` go
164
+ import (
165
+ " context"
166
+ " fmt"
167
+
168
+ " github.com/Azure/azure-sdk-for-go/sdk/azidentity"
169
+ " github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
170
+ )
171
+ ```
172
+
173
+ Add the following code to create the client object:
174
+
175
+ ``` go
176
+ func getClient (accountName string ) *azblob .Client {
177
+ accountURL := fmt.Printf (" https://%s .blob.core.windows.net" , accountName)
178
+
179
+ // Create a new service client with token credential
180
+ credential , err := azidentity.NewDefaultAzureCredential (nil )
181
+ handleError (err)
182
+
183
+ client , err := azblob.NewClient (accountURL, credential, nil )
184
+ handleError (err)
185
+
186
+ return client
187
+ }
188
+ ```
189
+
190
+ Instances of ` azblob.Client ` provide methods for working with containers and blobs within a storage account. Specify the storage account endpoint when constructing the client object.
191
+
158
192
---
159
193
160
194
### Create a BlobContainerClient object
@@ -203,6 +237,33 @@ def get_blob_container_client(self, blob_service_client: BlobServiceClient, cont
203
237
return container_client
204
238
```
205
239
240
+ ## [ Go] ( #tab/go )
241
+
242
+ Add the following ` import ` statements:
243
+
244
+ ``` go
245
+ import (
246
+ " context"
247
+ " fmt"
248
+
249
+ " github.com/Azure/azure-sdk-for-go/sdk/azidentity"
250
+ " github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
251
+ " github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
252
+ )
253
+ ```
254
+
255
+ Add the following code to create the container client object:
256
+
257
+ ``` go
258
+ func getBlobContainerClient (client *azblob .Client , containerName string ) *container .Client {
259
+ // Create the container client using the azblob client object
260
+ containerClient := client.ServiceClient ().NewContainerClient (containerName)
261
+ return containerClient
262
+ }
263
+ ```
264
+
265
+ Instances of ` azblob.Client ` provide methods for working with containers and blobs within a storage account. For most operations, you can use the ` azblob.Client ` instance rather than creating a separate ` container.Client ` instance.
266
+
206
267
---
207
268
208
269
If your work is narrowly scoped to a single container, you might choose to create a ` BlobContainerClient ` object directly without using ` BlobServiceClient ` . You can still set client options on a container client just like you would on a service client.
@@ -272,6 +333,36 @@ def get_blob_container_client(self, account_name, container_name):
272
333
return container_client
273
334
` ` `
274
335
336
+ ## [Go](#tab/go)
337
+
338
+ Add the following ` import ` statements:
339
+
340
+ ` ` ` go
341
+ import (
342
+ " context"
343
+ " fmt"
344
+
345
+ " github.com/Azure/azure-sdk-for-go/sdk/azidentity"
346
+ " github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
347
+ )
348
+ ` ` `
349
+
350
+ Add the following code to create the container client object:
351
+
352
+ ` ` ` go
353
+ func getBlobContainerClient (accountName string, containerName string) * container .Client {
354
+ // Create a new container client with token credential
355
+ credential, err := azidentity .NewDefaultAzureCredential (nil)
356
+ handleError (err)
357
+
358
+ containerURL := fmt .Sprintf (" https://%s.blob.core.windows.net/%s" , accountName, containerName)
359
+ containerClient, err := container .NewClient (containerURL, credential, nil)
360
+ handleError (err)
361
+
362
+ return containerClient
363
+ }
364
+ ` ` `
365
+
275
366
---
276
367
277
368
### Create a BlobClient object
@@ -324,6 +415,32 @@ def get_blob_client(self, blob_service_client: BlobServiceClient, container_name
324
415
return blob_client
325
416
` ` `
326
417
418
+ ## [Go](#tab/go)
419
+
420
+ Add the following ` import ` statements:
421
+
422
+ ` ` ` go
423
+ import (
424
+ " context"
425
+ " fmt"
426
+
427
+ " github.com/Azure/azure-sdk-for-go/sdk/azidentity"
428
+ " github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
429
+ )
430
+ ` ` `
431
+
432
+ Add the following code to create the blob client object:
433
+
434
+ ` ` ` go
435
+ func getBlobClient (client * azblob .Client , containerName string, blobName string) * blob .Client {
436
+ // Create the blob client using the azblob client object
437
+ blobClient := client .ServiceClient ().NewContainerClient (containerName).NewBlobClient (blobName)
438
+ return blobClient
439
+ }
440
+ ` ` `
441
+
442
+ Instances of ` azblob .Client ` provide methods for working with containers and blobs within a storage account. For most operations, you can use the ` azblob .Client ` instance rather than creating a separate ` blob .Client ` instance.
443
+
327
444
---
328
445
329
446
## Manage client objects
0 commit comments