Skip to content

Encourage use of Microsoft.Extensions.Azure for client registration #47576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

scottaddie
Copy link
Member

@scottaddie scottaddie commented Jul 25, 2025

Remove code samples that call AddSingleton. We want customers to use Microsoft.Extensions.Azure instead for client registration.

@scottaddie scottaddie requested review from jsquire, alexwolfmsft and a team as code owners July 25, 2025 15:35
@dotnetrepoman dotnetrepoman bot added this to the July 2025 milestone Jul 25, 2025
scottaddie and others added 2 commits July 25, 2025 10:47
Co-authored-by: Jesse Squire <jsquire@microsoft.com>
Co-authored-by: Jesse Squire <jsquire@microsoft.com>
@@ -37,7 +37,3 @@ Azure services are accessed using specialized client classes from the various Az
1. Pass an instance of `DefaultAzureCredential` to the `UseCredential` method.
Copy link
Member

@jsquire jsquire Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens by default. The only time that you need to call UseCredential on the builder is when you want to override the DefaultAzureCredential that it creates on your behalf. You could also call the chained WithCredential as part of the client registration to override the default credential for just that client.

builder.Services.AddAzureClients(clientBuilder =>
{
    clientBuilder
        .AddBlobServiceClient(new Uri("https://<account-name>.blob.core.windows.net"))
        .WithCredential(new AzureCliCredential());
});

@scottaddie scottaddie marked this pull request as draft July 25, 2025 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants