Skip to content

Commit a095841

Browse files
Update guidance and remove tables (#45123)
* Update credential guidance and remove tables Co-authored-by: Scott Addie <[email protected]>
1 parent 920bfa3 commit a095841

33 files changed

+330
-191
lines changed

docs/azure/media/app-registration.png

81.6 KB
Loading
53.8 KB
Loading

docs/azure/media/create-group.png

43.6 KB
Loading

docs/azure/sdk/authentication/local-development-service-principal.md

Lines changed: 151 additions & 132 deletions
Large diffs are not rendered by default.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
ms.topic: include
3+
ms.date: 02/12/2025
4+
---
5+
6+
## Authenticate to Azure services from your app
7+
8+
The [Azure Identity library](/dotnet/api/azure.identity?view=azure-dotnet&preserve-view=true) provides various *credentials*&mdash;implementations of `TokenCredential` adapted to supporting different scenarios and Microsoft Entra authentication flows. The steps ahead demonstrate how to use <xref:Azure.Identity.ClientSecretCredential> when working with service principals locally and in production.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
ms.topic: include
3+
ms.date: 02/12/2025
4+
---
5+
6+
[!INCLUDE [implement-service-principal-concepts](implement-service-principal-concepts.md)]
7+
8+
### Implement the code
9+
10+
Add the [Azure.Identity](/dotnet/api/azure.identity) package. In an ASP.NET Core project, also install the [Microsoft.Extensions.Azure](/dotnet/api/microsoft.extensions.azure) package:
11+
12+
### [Command Line](#tab/command-line)
13+
14+
In a terminal of your choice, navigate to the application project directory and run the following commands:
15+
16+
```dotnetcli
17+
dotnet add package Azure.Identity
18+
dotnet add package Microsoft.Extensions.Azure
19+
```
20+
21+
### [NuGet Package Manager](#tab/nuget-package)
22+
23+
Right-click your project in the Visual Studio **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.
24+
25+
:::image type="content" source="../media/nuget-azure-identity.png" alt-text="Install a package using the package manager.":::
26+
27+
---
28+
29+
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 for dependency injection so they can be used throughout your app. In `Program.cs`, complete the following steps to configure a client class for dependency injection and token-based authentication:
30+
31+
1. Include the `Azure.Identity` and `Microsoft.Extensions.Azure` namespaces via `using` directives.
32+
1. Register the Azure service client using the corresponding `Add`-prefixed extension method.
33+
1. Configure `ClientSecretCredential` with the `tenantId`, `clientId`, and `clientSecret`.
34+
1. Pass the `ClientSecretCredential` instance to the `UseCredential` method.
35+
36+
:::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/includes/local-dev-app-registration-azure-portal-1.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/azure/sdk/includes/local-dev-app-registration-azure-portal-2.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/azure/sdk/includes/local-dev-app-registration-azure-portal-3.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/azure/sdk/includes/local-dev-app-registration-azure-portal-4.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)