Skip to content

Commit 76e06d7

Browse files
authored
changed files by pdets auto publish service, publishid[6412cf20-b290-440d-acb1-e2eb9eeeb7c6] and do [publish].
1 parent c1315cf commit 76e06d7

15 files changed

+125
-26
lines changed

learn-pr/wwl-azure/work-azure-blob-storage/1-introduction.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Introduction
44
metadata:
55
title: Introduction
66
description: "Introduction"
7-
ms.date: 02/06/2023
7+
ms.date: 04/18/2023
88
author: wwlpublish
99
ms.author: jeffko
1010
ms.topic: interactive-tutorial

learn-pr/wwl-azure/work-azure-blob-storage/2-blob-storage-client-library-overview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Explore Azure Blob storage client library
44
metadata:
55
title: Explore Azure Blob storage client library
66
description: "Explore Azure Blob storage client library"
7-
ms.date: 02/06/2023
7+
ms.date: 04/18/2023
88
author: wwlpublish
99
ms.author: jeffko
1010
ms.topic: interactive-tutorial
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.work-azure-blob-storage.create-client-object
3+
title: Create a client object
4+
metadata:
5+
title: Create a client object
6+
description: "Create a client object"
7+
ms.date: 04/18/2023
8+
author: wwlpublish
9+
ms.author: jeffko
10+
ms.topic: interactive-tutorial
11+
ms.prod: learning-azure
12+
durationInMinutes: 5
13+
content: |
14+
[!include[](includes/3-create-client-object.md)]

learn-pr/wwl-azure/work-azure-blob-storage/3-develop-blob-storage-dotnet.yml renamed to learn-pr/wwl-azure/work-azure-blob-storage/4-develop-blob-storage-dotnet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ title: 'Exercise: Create Blob storage resources by using the .NET client library
44
metadata:
55
title: 'Exercise: Create Blob storage resources by using the .NET client library'
66
description: "Exercise: Create Blob storage resources by using the .NET client library"
7-
ms.date: 02/06/2023
7+
ms.date: 04/18/2023
88
author: wwlpublish
99
ms.author: jeffko
1010
ms.topic: interactive-tutorial
1111
ms.prod: learning-azure
1212
durationInMinutes: 15
1313
content: |
14-
[!include[](includes/3-develop-blob-storage-dotnet.md)]
14+
[!include[](includes/4-develop-blob-storage-dotnet.md)]

learn-pr/wwl-azure/work-azure-blob-storage/4-manage-container-properties-metadata-dotnet.yml renamed to learn-pr/wwl-azure/work-azure-blob-storage/5-manage-container-properties-metadata-dotnet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ title: Manage container properties and metadata by using .NET
44
metadata:
55
title: Manage container properties and metadata by using .NET
66
description: "Manage container properties and metadata by using .NET"
7-
ms.date: 02/06/2023
7+
ms.date: 04/18/2023
88
author: wwlpublish
99
ms.author: jeffko
1010
ms.topic: interactive-tutorial
1111
ms.prod: learning-azure
1212
durationInMinutes: 3
1313
content: |
14-
[!include[](includes/4-manage-container-properties-metadata-dotnet.md)]
14+
[!include[](includes/5-manage-container-properties-metadata-dotnet.md)]

learn-pr/wwl-azure/work-azure-blob-storage/5-set-retrieve-properties-metadata-rest.yml renamed to learn-pr/wwl-azure/work-azure-blob-storage/6-set-retrieve-properties-metadata-rest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ title: Set and retrieve properties and metadata for blob resources by using REST
44
metadata:
55
title: Set and retrieve properties and metadata for blob resources by using REST
66
description: "Set and retrieve properties and metadata for blob resources by using REST"
7-
ms.date: 02/06/2023
7+
ms.date: 04/18/2023
88
author: wwlpublish
99
ms.author: jeffko
1010
ms.topic: interactive-tutorial
1111
ms.prod: learning-azure
1212
durationInMinutes: 3
1313
content: |
14-
[!include[](includes/5-set-retrieve-properties-metadata-rest.md)]
14+
[!include[](includes/6-set-retrieve-properties-metadata-rest.md)]

learn-pr/wwl-azure/work-azure-blob-storage/6-knowledge-check.yml renamed to learn-pr/wwl-azure/work-azure-blob-storage/7-knowledge-check.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Knowledge check
44
metadata:
55
title: Knowledge check
66
description: "Knowledge check"
7-
ms.date: 02/06/2023
7+
ms.date: 04/18/2023
88
author: wwlpublish
99
ms.author: jeffko
1010
ms.topic: interactive-tutorial
@@ -17,21 +17,21 @@ quiz:
1717
choices:
1818
- content: "Last-Modified"
1919
isCorrect: true
20-
explanation: "That's correct. Last-Modified is supported on both containers and blobs."
20+
explanation: "Correct. Last-Modified is supported on both containers and blobs."
2121
- content: "Content-Length"
2222
isCorrect: false
23-
explanation: "That's incorrect. Content-Length is only supported on blobs."
23+
explanation: "Incorrect. Content-Length is only supported on blobs."
2424
- content: "Origin"
2525
isCorrect: false
26-
explanation: "That's incorrect. Origin is only supported on blobs."
26+
explanation: "Incorrect. Origin is only supported on blobs."
2727
- content: "Which of the following classes of the Azure Storage client library for .NET allows you to manipulate both Azure Storage containers and their blobs?"
2828
choices:
2929
- content: "BlobClient"
3030
isCorrect: false
31-
explanation: "That's incorrect. The BlobClient class is limited to manipulating blobs."
31+
explanation: "Incorrect. The BlobClient class is limited to manipulating blobs."
3232
- content: "BlobContainerClient"
3333
isCorrect: true
34-
explanation: "That's correct. The BlobContainerClient can be used to manipulate both containers and blobs."
34+
explanation: "Correct. The BlobContainerClient can be used to manipulate both containers and blobs."
3535
- content: "BlobUriBuilder"
3636
isCorrect: false
37-
explanation: "That's incorrect. The BlobUriBuilder provides a way to modify the contents of a Uri instance to point to different Azure Storage resources like an account, container, or blob."
37+
explanation: "Incorrect. The BlobUriBuilder provides a way to modify the contents of a Uri instance to point to different Azure Storage resources like an account, container, or blob."

learn-pr/wwl-azure/work-azure-blob-storage/7-summary.yml renamed to learn-pr/wwl-azure/work-azure-blob-storage/8-summary.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ title: Summary
44
metadata:
55
title: Summary
66
description: "Summary"
7-
ms.date: 02/06/2023
7+
ms.date: 04/18/2023
88
author: wwlpublish
99
ms.author: jeffko
1010
ms.topic: interactive-tutorial
1111
ms.prod: learning-azure
1212
durationInMinutes: 3
1313
content: |
14-
[!include[](includes/7-summary.md)]
14+
[!include[](includes/8-summary.md)]
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11

22
The Azure Storage client libraries for .NET offer a convenient interface for making calls to Azure Storage. The latest version of the Azure Storage client library is version 12.x. Microsoft recommends using version 12.x for new applications.
33

4-
Below are the classes in the Azure.Storage.Blobs namespace and their purpose:
4+
The following table lists the basic classes, along with a brief description:
55

6-
Class | Description
7-
-- | --
8-
`BlobClient` | The `BlobClient` allows you to manipulate Azure Storage blobs.
9-
`BlobClientOptions` | Provides the client configuration options for connecting to Azure Blob Storage.
10-
`BlobContainerClient` | The `BlobContainerClient` allows you to manipulate Azure Storage containers and their blobs.
11-
`BlobServiceClient` | The `BlobServiceClient` allows you to manipulate Azure Storage service resources and blob containers. The storage account provides the top-level namespace for the Blob service.
12-
`BlobUriBuilder` | The `BlobUriBuilder` class provides a convenient way to modify the contents of a Uri instance to point to different Azure Storage resources like an account, container, or blob.
6+
| Class | Description |
7+
|--|--|
8+
| `BlobServiceClient` | Represents the storage account, and provides operations to retrieve and configure account properties, and to work with blob containers in the storage account. |
9+
| `BlobContainerClient` | Represents a specific blob container, and provides operations to work with the container and the blobs within. |
10+
| `BlobClient` | Represents a specific blob, and provides general operations to work with the blob, including operations to upload, download, delete, and create snapshots. |
11+
| `AppendBlobClient` | Represents an append blob, and provides operations specific to append blobs, such as appending log data. |
12+
| `BlockBlobClient` | Represents a block blob, and provides operations specific to block blobs, such as staging and then committing blocks of data. |
1313

14+
The following packages contain the classes used to work with Blob Storage data resources:
1415

16+
* [Azure.Storage.Blobs](/dotnet/api/azure.storage.blobs): Contains the primary classes (client objects) that you can use to operate on the service, containers, and blobs.
17+
* [Azure.Storage.Blobs.Specialized](/dotnet/api/azure.storage.blobs.specialized): Contains classes that you can use to perform operations specific to a blob type, such as block blobs.
18+
* [Azure.Storage.Blobs.Models](/dotnet/api/azure.storage.blobs.models): All other utility classes, structures, and enumeration types.
1519

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
3+
Working with any Azure resource using the SDK begins with creating a client object. In this section, you learn how to create client objects to interact with the three types of resources in the storage service: storage accounts, containers, and blobs.
4+
5+
When your application creates a client object, you pass a URI referencing the endpoint to the client constructor. You can construct the endpoint string manually, as shown in the examples in this article, or you can query for the endpoint at runtime using the Azure Storage management library.
6+
7+
The code samples in this unit use [DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential) to authenticate to Azure via an Azure Active Directory (Azure AD) security principal. The authentication process includes obtaining an access token for authorization. This access token is passed as a credential when the client is instantiated, and the credential persists throughout the client lifetime. The Azure AD security principal requesting the token must be assigned an appropriate Azure RBAC role that grants access to blob data.
8+
9+
## Create a BlobServiceClient object
10+
11+
An authorized `BlobServiceClient` object allows your app to interact with resources at the storage account level. `BlobServiceClient` provides methods to retrieve and configure account properties, as well as list, create, and delete containers within the storage account. This client object is the starting point for interacting with resources in the storage account.
12+
13+
The following example shows how to create a `BlobServiceClient` object:
14+
15+
```csharp
16+
using Azure.Identity;
17+
using Azure.Storage.Blobs;
18+
19+
public BlobServiceClient GetBlobServiceClient(string accountName)
20+
{
21+
BlobServiceClient client = new(
22+
new Uri($"https://{accountName}.blob.core.windows.net"),
23+
new DefaultAzureCredential());
24+
25+
return client;
26+
}
27+
```
28+
29+
## Create a BlobContainerClient object
30+
31+
You can use a `BlobServiceClient` object to create a new `BlobContainerClient` object. A `BlobContainerClient` object allows you to interact with a specific container resource. `BlobContainerClient` provides methods to create, delete, or configure a container, and includes methods to list, upload, and delete the blobs within it.
32+
33+
The following example shows how to create a container client from a `BlobServiceClient` object to interact with a specific container resource:
34+
35+
```csharp
36+
public BlobContainerClient GetBlobContainerClient(
37+
BlobServiceClient blobServiceClient,
38+
string containerName)
39+
{
40+
// Create the container client using the service client object
41+
BlobContainerClient client = blobServiceClient.GetBlobContainerClient(containerName);
42+
return client;
43+
}
44+
```
45+
46+
If your work is narrowly scoped to a single container, you might choose to create a `BlobContainerClient` object directly without using `BlobServiceClient`.
47+
48+
```csharp
49+
public BlobContainerClient GetBlobContainerClient(
50+
string accountName,
51+
string containerName,
52+
BlobClientOptions clientOptions)
53+
{
54+
// Append the container name to the end of the URI
55+
BlobContainerClient client = new(
56+
new Uri($"https://{accountName}.blob.core.windows.net/{containerName}"),
57+
new DefaultAzureCredential(),
58+
clientOptions);
59+
60+
return client;
61+
}
62+
```
63+
64+
## Create a BlobClient object
65+
66+
To interact with a specific blob resource, create a `BlobClient` object from a service client or container client. A `BlobClient` object allows you to interact with a specific blob resource.
67+
68+
The following example shows how to create a blob client to interact with a specific blob resource:
69+
70+
```csharp
71+
public BlobClient GetBlobClient(
72+
BlobServiceClient blobServiceClient,
73+
string containerName,
74+
string blobName)
75+
{
76+
BlobClient client =
77+
blobServiceClient.GetBlobContainerClient(containerName).GetBlobClient(blobName);
78+
return client;
79+
}
80+
```

0 commit comments

Comments
 (0)