Skip to content

Commit 9ba7a8c

Browse files
Update snippet
1 parent b3e2296 commit 9ba7a8c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ To authorize with Azure AD, you'll need to use a security principal. The type of
8282

8383
An easy and secure way to authorize access and connect to Blob Storage is to obtain an OAuth token by creating a [DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential) instance. You can then use that credential to create a [BlobServiceClient](/dotnet/api/azure.storage.blobs.blobserviceclient) object.
8484

85-
The following example creates a `BlobServiceClient` object using `DefaultAzureCredential`:
85+
The following example creates a `BlobServiceClient` object authorized using `DefaultAzureCredential`:
8686

8787
```csharp
88-
public static void GetBlobServiceClient(ref BlobServiceClient blobServiceClient, string accountName)
88+
public BlobServiceClient GetBlobServiceClient(string accountName)
8989
{
90-
TokenCredential credential = new DefaultAzureCredential();
90+
BlobServiceClient client = new(
91+
new Uri($"https://{accountName}.blob.core.windows.net"),
92+
new DefaultAzureCredential());
9193

92-
string blobUri = "https://" + accountName + ".blob.core.windows.net";
93-
94-
blobServiceClient = new BlobServiceClient(new Uri(blobUri), credential);
94+
return client;
9595
}
9696
```
9797

0 commit comments

Comments
 (0)