From 7c6b06f2ca11ac0be7dccd1aa4c0227e20e29f5c Mon Sep 17 00:00:00 2001 From: BillWagner <493969+BillWagner@users.noreply.github.com> Date: Mon, 16 Nov 2026 18:56:15 +0000 Subject: [PATCH 1/2] Initial plan From d089e592df3036989681a08f9c4c77f3658cf801 Mon Sep 17 00:00:00 2001 From: BillWagner <493969+BillWagner@users.noreply.github.com> Date: Mon, 16 Nov 2026 18:59:43 +0000 Subject: [PATCH 2/2] Fix DefaultAzureCredential documentation example Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- docs/azure/sdk/aspnetcore-guidance.md | 4 ++-- .../sdk/snippets/aspnetcore-guidance/BlazorSample/Program.cs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/azure/sdk/aspnetcore-guidance.md b/docs/azure/sdk/aspnetcore-guidance.md index 9b85b132c594a..18af83371873d 100644 --- a/docs/azure/sdk/aspnetcore-guidance.md +++ b/docs/azure/sdk/aspnetcore-guidance.md @@ -47,7 +47,7 @@ Complete the following steps to register the services you need: 3. In the `Program.cs` file of your app, invoke the extension method from the `Microsoft.Extensions.Azure` library to register a client to communicate with each Azure service. Some client libraries provide additional [subclients](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-subclients) for specific subgroups of Azure service functionality. You can register such subclients for dependency injection via the extension method. - :::code language="csharp" source="snippets/aspnetcore-guidance/BlazorSample/Program.cs" range="11-30" highlight="4-7,13-15"::: + :::code language="csharp" source="snippets/aspnetcore-guidance/BlazorSample/Program.cs" range="11-28" highlight="5-8,14-17"::: 4. Inject the registered clients into your ASP.NET Core app components, services, or API endpoint: @@ -82,7 +82,7 @@ Use the [Azure Identity](/dotnet/api/overview/azure/identity-readme) library for 1. In the `Program.cs` file of your app, invoke the extension method from the `Microsoft.Extensions.Azure` library to set a shared `DefaultAzureCredential` instance for all registered Azure service clients: - :::code language="csharp" source="snippets/aspnetcore-guidance/BlazorSample/Program.cs" range="11-30" ::: + :::code language="csharp" source="snippets/aspnetcore-guidance/BlazorSample/Program.cs" range="13-13" ::: `DefaultAzureCredential` discovers available credentials in the current environment and uses them to authenticate to Azure services. For the order and locations in which `DefaultAzureCredential` scans for credentials, see [DefaultAzureCredential overview](/dotnet/azure/sdk/authentication/credential-chains?tabs=dac#defaultazurecredential-overview). Using a shared `DefaultAzureCredential` instance ensures the underlying token cache is used, which improves application resilience and performance due to fewer requests for a new token. diff --git a/docs/azure/sdk/snippets/aspnetcore-guidance/BlazorSample/Program.cs b/docs/azure/sdk/snippets/aspnetcore-guidance/BlazorSample/Program.cs index 84f566ce100b5..8a9e7e35dc0bb 100644 --- a/docs/azure/sdk/snippets/aspnetcore-guidance/BlazorSample/Program.cs +++ b/docs/azure/sdk/snippets/aspnetcore-guidance/BlazorSample/Program.cs @@ -10,6 +10,8 @@ builder.Services.AddAzureClients(clientBuilder => { + clientBuilder.UseCredential(new DefaultAzureCredential()); + // Register a client for each Azure service using inline configuration clientBuilder.AddSecretClient(new Uri("")); clientBuilder.AddBlobServiceClient(new Uri(""));