You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,29 +11,30 @@ The [Azure Identity library](/dotnet/api/azure.identity?view=azure-dotnet&preser
11
11
12
12
[DefaultAzureCredential](../authentication/credential-chains.md#defaultazurecredential-overview) is an opinionated, ordered sequence of mechanisms for authenticating to Microsoft Entra ID. Each authentication mechanism is a class derived from the [TokenCredential](/dotnet/api/azure.core.tokencredential?view=azure-dotnet&preserve-view=true) class and is known as a *credential*. At runtime, `DefaultAzureCredential` attempts to authenticate using the first credential. If that credential fails to acquire an access token, the next credential in the sequence is attempted, and so on, until an access token is successfully obtained. In this way, your app can use different credentials in different environments without writing environment-specific code.
13
13
14
-
To use `DefaultAzureCredential`, add the [Azure.Identity](/dotnet/api/azure.identity) and optionally the [Microsoft.Extensions.Azure](/dotnet/api/microsoft.extensions.azure) packages to your application:
14
+
To use `DefaultAzureCredential`:
15
15
16
-
### [Command Line](#tab/command-line)
16
+
1. Add the [Microsoft.Extensions.Azure](/dotnet/api/microsoft.extensions.azure) package to your application:
17
17
18
-
In a terminal of your choice, navigate to the application project directory and run the following commands:
18
+
```dotnetcli
19
+
dotnet add package Microsoft.Extensions.Azure
20
+
```
19
21
20
-
```dotnetcli
21
-
dotnet add package Azure.Identity
22
-
dotnet add package Microsoft.Extensions.Azure
23
-
```
22
+
1. Azure services are accessed using specialized client classes from the various Azure SDK client libraries. These classes and your own custom services should be registered so they can be accessed via dependency injection throughout your app. In `Program.cs`, complete the following steps to register a client class and `DefaultAzureCredential`:
24
23
25
-
### [NuGet Package Manager](#tab/nuget-package)
24
+
1. Include the `Microsoft.Extensions.Azure` namespace via a `using` directive.
25
+
1. Register the Azure service client using the corresponding `Add`-prefixed extension method.
26
26
27
-
Right-click your project in Visual Studio's **Solution Explorer** window and select **Manage NuGet Packages**. Search for **Azure.Identity**, and install the matching package. Repeat this process for the **Microsoft.Extensions.Azure** package.
:::image type="content" source="../media/nuget-azure-identity.png" alt-text="Install a package using the package manager.":::
29
+
By default, the client builder creates a `DefaultAzureCredential` instance on your behalf. For production usage, register a [deterministic credential](../authentication/best-practices.md#use-deterministic-credentials-in-production-environments) instance with the builder instead of using `DefaultAzureCredential`. To use a different credential for Azure SDK clients:
30
30
31
-
---
31
+
1. Add the [Azure.Identity](/dotnet/api/azure.identity) package to your application:
32
32
33
-
Azure services are accessed using specialized client classes from the various Azure SDK client libraries. These classes and your own custom services should be registered so they can be accessed via dependency injection throughout your app. In `Program.cs`, complete the following steps to register a client class and `DefaultAzureCredential`:
33
+
```dotnetcli
34
+
dotnet add package Azure.Identity
35
+
```
34
36
35
-
1. Include the `Azure.Identity` and `Microsoft.Extensions.Azure` namespaces via `using` directives.
36
-
1. Register the Azure service client using the corresponding `Add`-prefixed extension method.
37
-
1. Pass an instance of `DefaultAzureCredential` to the `UseCredential` method.
37
+
1. Include the `Azure.Identity` namespace via a `using` directive.
38
+
1. Register a custom credential instance with the builder. For example:
0 commit comments