Skip to content

Commit

Permalink
Merge branch 'tokens-from-configuration' of https://github.com/alexwo…
Browse files Browse the repository at this point in the history
…lfmsft/docs into tokens-from-configuration
  • Loading branch information
alexwolfmsft committed Jan 26, 2024
2 parents 4432068 + 8f028c1 commit 3ea19de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/azure/TOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
href: ./sdk/authentication/azure-hosted-apps.md
- name: Auth from on-premises apps
href: ./sdk/authentication/on-premises-apps.md
- name: Auth from configuration files
- name: Auth via configuration files
href: ./sdk/authentication/create-token-credentials-from-configuration.md
- name: Additional auth methods
href: ./sdk/authentication/additional-methods.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
title: Create token credentials from configuration
description: This article describes how to create token credentials from configuration files
description: This article describes how to create Microsoft Entra token credentials from configuration files.
ms.topic: how-to
ms.custom: devx-track-dotnet, engagement-fy23
ms.date: 1/16/2024
---

# Create Azure credential types using configuration files
# Create Microsoft Entra credential types using configuration files

The `Microsoft.Extensions.Azure` library supports creating different <xref:Azure.Core.TokenCredential?displayProperty=fullName> types from values defined in _appsettings.json_ and other configuration files. This article describes the support for different `TokenCredential` types and how to configure the required values for each type.

## Support for Azure credentials through configuration

The [`Microsoft.Extensions.Azure`](https://www.nuget.org/packages/Microsoft.Extensions.Azure) library can automatically provide Azure service clients with a `TokenCredential` class by searching _appsettings.json_ or other configuration files for credential values using the default `IConfiguration` service for .NET. This approach allows developers to explicitly set credential values across different environments through configuration rather than through app code directly.
The [`Microsoft.Extensions.Azure`](https://www.nuget.org/packages/Microsoft.Extensions.Azure) library can automatically provide Azure service clients with a `TokenCredential` class by searching _appsettings.json_ or other configuration files for credential values using the `IConfiguration` abstraction for .NET. This approach allows developers to explicitly set credential values across different environments through configuration rather than through app code directly.

The following credential types are supported via configuration:

Expand All @@ -22,9 +22,9 @@ The following credential types are supported via configuration:
* [ManagedIdentityCredential](#create-a-managedidentitycredential-type)
* [WorkloadIdentityCredential](#create-a-workloadidentitycredential-type)

## Configuring Azure credentials
## Configure Azure credentials

Azure service clients registered with the `AddAzureClients` method are automatically configured with an instance of `DefaultAzureCredential`. You can override the global `DefaultAzureCredential` using credential values from configuration files when registering a client:
Azure service clients registered with the `AddAzureClients` method are automatically configured with an instance of `DefaultAzureCredential` if no explicit credential is supplied via the `WithCredential` extension method. You can also override the global `DefaultAzureCredential` using credential values from configuration files when registering a client:

```csharp
builder.Services.AddAzureClients(clientBuilder =>
Expand Down Expand Up @@ -54,7 +54,7 @@ You can create both user-assigned and system-assigned managed identities using c

#### User-assigned identities

1. Authenticate using a client ID:
1. Specify a user-assigned managed identity via a client ID:

```json
{
Expand All @@ -63,7 +63,7 @@ You can create both user-assigned and system-assigned managed identities using c
}
```

1. Authenticate using a resource ID:
1. Specify a user-assigned managed identity via a resource ID:

```json
{
Expand All @@ -76,7 +76,7 @@ You can create both user-assigned and system-assigned managed identities using c

#### System-assigned identities

1. Authenticate using a client ID:
1. Configure managed identity with a system-assigned identity:

```json
{
Expand Down Expand Up @@ -105,7 +105,7 @@ Add the following configuration values to your _appsettings.json_ file to create
{
"tenantId": "<tenantId>",
"clientId": "<clientId>",
"tokenFilePath": "<clientSecret>"
"clientSecret": "<clientSecret>"
}
```

Expand Down

0 comments on commit 3ea19de

Please sign in to comment.