Skip to content

Commit 9dafb48

Browse files
committed
Encourage use of Microsoft.Extensions.Azure for client registration
1 parent 76b8518 commit 9dafb48

File tree

4 files changed

+2
-30
lines changed

4 files changed

+2
-30
lines changed

docs/azure/sdk/includes/implement-defaultazurecredential.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
ms.topic: include
3-
ms.date: 04/25/2025
3+
ms.date: 07/25/2025
44
---
55

66
## Authenticate to Azure services from your app
@@ -37,7 +37,3 @@ Azure services are accessed using specialized client classes from the various Az
3737
1. Pass an instance of `DefaultAzureCredential` to the `UseCredential` method.
3838

3939
:::code language="csharp" source="../snippets/authentication/local-dev-account/Program.cs" id="snippet_DefaultAzureCredential_UseCredential":::
40-
41-
An alternative to the `UseCredential` method is to provide the credential to the service client directly:
42-
43-
:::code language="csharp" source="../snippets/authentication/local-dev-account/Program.cs" id="snippet_DefaultAzureCredential":::

docs/azure/sdk/includes/implement-service-principal.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
ms.topic: include
3-
ms.date: 02/12/2025
3+
ms.date: 07/25/2025
44
---
55

66
[!INCLUDE [implement-service-principal-concepts](implement-service-principal-concepts.md)]
@@ -34,7 +34,3 @@ Azure services are accessed using specialized client classes from the various Az
3434
1. Pass the `ClientSecretCredential` instance to the `UseCredential` method.
3535

3636
:::code language="csharp" source="../snippets/authentication/local-dev-service-principal/Program.cs" id="snippet_ClientSecretCredential_UseCredential":::
37-
38-
An alternative to the `UseCredential` method is to provide the credential to the service client directly:
39-
40-
:::code language="csharp" source="../snippets/authentication/local-dev-service-principal/Program.cs" id="snippet_ClientSecretCredential":::

docs/azure/sdk/snippets/authentication/local-dev-account/Program.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Azure.Identity;
22
using Microsoft.Extensions.Azure;
33
using Azure.Storage.Blobs;
4-
using Azure.Core;
54

65
var builder = WebApplication.CreateBuilder(args);
76

@@ -54,13 +53,6 @@ void registerUsingServicePrincipal(WebApplicationBuilder builder)
5453
clientBuilder.UseCredential(new DefaultAzureCredential());
5554
});
5655
#endregion snippet_DefaultAzureCredential_UseCredential
57-
58-
#region snippet_DefaultAzureCredential
59-
builder.Services.AddSingleton<BlobServiceClient>(_ =>
60-
new BlobServiceClient(
61-
new Uri("https://<account-name>.blob.core.windows.net"),
62-
new DefaultAzureCredential()));
63-
#endregion snippet_DefaultAzureCredential
6456
}
6557

6658
internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)

docs/azure/sdk/snippets/authentication/local-dev-service-principal/Program.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Azure.Identity;
22
using Microsoft.Extensions.Azure;
33
using Azure.Storage.Blobs;
4-
using Azure.Core;
54

65
var builder = WebApplication.CreateBuilder(args);
76

@@ -58,17 +57,6 @@ void registerUsingServicePrincipal(WebApplicationBuilder builder)
5857
clientBuilder.UseCredential(new ClientSecretCredential(tenantId, clientId, clientSecret));
5958
});
6059
#endregion snippet_ClientSecretCredential_UseCredential
61-
62-
#region snippet_ClientSecretCredential
63-
var tenantId = Environment.GetEnvironmentVariable("AZURE_TENANT_ID");
64-
var clientId = Environment.GetEnvironmentVariable("AZURE_CLIENT_ID");
65-
var clientSecret = Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET");
66-
67-
builder.Services.AddSingleton<BlobServiceClient>(_ =>
68-
new BlobServiceClient(
69-
new Uri("https://<account-name>.blob.core.windows.net"),
70-
new ClientSecretCredential(tenantId, clientId, clientSecret)));
71-
#endregion snippet_ClientSecretCredential
7260
}
7361

7462
internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)

0 commit comments

Comments
 (0)