Skip to content

Commit

Permalink
Add clarity to UseCredential call (#43591)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottaddie authored Nov 15, 2024
1 parent eb12a9f commit d37f469
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions docs/azure/sdk/authentication/credential-chains.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: 'Credential chains in the Azure Identity library for .NET'
description: 'This article describes the DefaultAzureCredential and ChainedTokenCredential classes in the Azure Identity library.'
ms.topic: conceptual
ms.date: 11/12/2024
ms.date: 11/15/2024
---

# Credential chains in the Azure Identity library for .NET
Expand Down Expand Up @@ -63,7 +63,10 @@ The order in which `DefaultAzureCredential` attempts credentials follows.

In its simplest form, you can use the parameterless version of `DefaultAzureCredential` as follows:

:::code language="csharp" source="../snippets/authentication/credential-chains/Program.cs" id="snippet_Dac":::
:::code language="csharp" source="../snippets/authentication/credential-chains/Program.cs" id="snippet_Dac" highlight="1":::

> [!TIP]
> The `UseCredential` method in the preceding code snippet is recommended for use in ASP.NET Core apps. For more information, see [Use the Azure SDK for .NET in ASP.NET Core apps](../aspnetcore-guidance.md#authenticate-using-microsoft-entra-id).
### How to customize DefaultAzureCredential

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<ItemGroup>
<!-- Azure SDK packages -->
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
<PackageVersion Include="Azure.Identity" Version="1.13.1" />
<PackageVersion Include="Azure.Identity.Broker" Version="1.1.0" />
<PackageVersion Include="Azure.Storage.Blobs" Version="12.21.2" />
<PackageVersion Include="Microsoft.Extensions.Azure" Version="1.7.5" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net9.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
clientBuilder.AddBlobServiceClient(
new Uri("https://<account-name>.blob.core.windows.net"));
#region snippet_Dac
clientBuilder.UseCredential(new DefaultAzureCredential());
DefaultAzureCredential credential = new();
clientBuilder.UseCredential(credential);
#endregion snippet_Dac
#region snippet_DacExcludes
Expand Down

0 comments on commit d37f469

Please sign in to comment.