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
Copy file name to clipboardExpand all lines: docs/azure/sdk/authentication/index.md
+10-3Lines changed: 10 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,13 +32,13 @@ Use of connection strings should be limited to scenarios where token-based authe
32
32
33
33
The specific type of token-based authentication an app should use to authenticate to Azure resources depends on where the app runs. The following diagram provides guidance for different scenarios and environments:
34
34
35
-
:::image type="content" source="../media/dotnet-sdk-auth-strategy.png" alt-text="A diagram showing the recommended token-based authentication strategies for an app depending on where it's running." :::
35
+
:::image type="content" source="../media/mermaidjs/authentication-environments.svg" alt-text="A diagram showing the recommended token-based authentication strategies for an app depending on where it's running." :::
36
36
37
37
When an app is:
38
38
39
39
-**Hosted on Azure**: The app should authenticate to Azure resources using a managed identity. This option is discussed in more detail at [authentication in server environments](#authentication-for-azure-hosted-apps).
40
-
-**Running locally during development**: The app can authenticate to Azure using either an application service principal for localdevelopment or by using the developer's Azure credentials. Each option is discussed in more detail at [authentication during local development](#authentication-during-local-development).
41
-
-**Hosted on-premises**: The app should authenticate to Azure resources using an application service principal, or a managed identity in the case of Azure Arc. On-premises workflows are discussed in more detail at [authentication in server environments](#authentication-for-apps-hosted-on-premises).
40
+
-**Running locally during development**: The app can authenticate to Azure using a [developer account](local-development-dev-accounts.md), a [broker](local-development-broker.md), or a [service principal](local-development-service-principal.md). Each option is discussed in more detail at [authentication during local development](#authentication-during-local-development).
41
+
-**Hosted on-premises**: The app should authenticate to Azure resources using an application service principal, or a managed identity in the case of Azure Arc. On-premises workflows are discussed in more detail at [Authentication for apps hosted on-premises](#authentication-for-apps-hosted-on-premises).
42
42
43
43
## Authentication for Azure-hosted apps
44
44
@@ -69,6 +69,13 @@ You can use your own Azure credentials to authenticate to Azure resources during
69
69
> [!div class="nextstepaction"]
70
70
> [Authenticate locally using developer credentials](local-development-dev-accounts.md)
71
71
72
+
#### Use a broker
73
+
74
+
Brokered authentication collects user credentials using the system authentication broker to authenticate an app. A system authentication broker runs on a user's machine and manages the authentication handshakes and token maintenance for all connected accounts.
75
+
76
+
> [!div class="nextstepaction"]
77
+
> [Authenticate locally using a broker](local-development-broker.md)
78
+
72
79
#### Use a service principal
73
80
74
81
A service principal is created in a Microsoft Entra tenant to represent an app and be used to authenticate to Azure resources. You can configure your app to use service principal credentials during local development. This method is more secure than using developer credentials and is closer to how your app will authenticate in production. However, it's still less ideal than using a managed identity due to the need for secrets.
Copy file name to clipboardExpand all lines: docs/azure/sdk/authentication/local-development-dev-accounts.md
+38-10Lines changed: 38 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,21 +12,28 @@ ms.custom:
12
12
13
13
# Authenticate .NET apps to Azure services during local development using developer accounts
14
14
15
-
During local development, applications need to authenticate to Azure to access various Azure services. Two common approaches for local authentication are to [use a service principal](local-development-service-principal.md) or to use a developer account. This article explains how to use a developer account. In the sections ahead, you learn:
15
+
During local development, applications need to authenticate to Azure to use different Azure services. Authenticate locally using one of these approaches:
16
16
17
-
- How to use Microsoft Entra groups to efficiently manage permissions for multiple developer accounts
18
-
- How to assign roles to developer accounts to scope permissions
19
-
- How to sign-in to supported local development tools
20
-
- How to authenticate using a developer account from your app code
17
+
- Use a developer account with one of the [developer tools supported by the Azure Identity library](#supported-developer-tools-for-authentication).
18
+
- Use a [broker](local-development-broker.md) to manage credentials.
19
+
- Use a [service principal](local-development-service-principal.md).
21
20
22
-
:::image type="content" source="../media/local-dev-dev-accounts-overview.png" alt-text="A diagram showing an app running in local development using a developer tool identity to connect to Azure resources.":::
21
+
This article explains how to authenticate using a developer account with tools supported by the Azure Identity library. In the sections ahead, you learn:
22
+
23
+
- How to use Microsoft Entra groups to efficiently manage permissions for multiple developer accounts.
24
+
- How to assign roles to developer accounts to scope permissions.
25
+
- How to sign-in to supported local development tools.
26
+
- How to authenticate using a developer account from your app code.
27
+
28
+
## Supported developer tools for authentication
23
29
24
30
For an app to authenticate to Azure during local development using the developer's Azure credentials, the developer must be signed-in to Azure from one of the following developer tools:
25
31
26
32
- Azure CLI
27
33
- Azure Developer CLI
28
34
- Azure PowerShell
29
35
- Visual Studio
36
+
- Visual Studio Code
30
37
31
38
The Azure Identity library can detect that the developer is signed-in from one of these tools. The library can then obtain the Microsoft Entra access token via the tool to authenticate the app to Azure as the signed-in user.
32
39
@@ -44,9 +51,30 @@ Next, sign-in to Azure using one of several developer tools that can be used to
### [Visual Studio Code](#tab/sign-in-visual-studio-code)
55
+
56
+
Developers using Visual Studio Code can authenticate with their developer account directly through the editor via the broker. Apps that use <xref:Azure.Identity.DefaultAzureCredential> or <xref:Azure.Identity.VisualStudioCodeCredential> can then use this account to authenticate app requests through a seamless single-sign-on experience.
57
+
58
+
1. In Visual Studio Code, go to the **Extensions** panel and install the [Azure Resources](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureresourcegroups) extension. This extension lets you view and manage Azure resources directly from Visual Studio Code. It also uses the built-in Visual Studio Code Microsoft authentication provider to authenticate with Azure.
59
+
60
+
:::image type="content" source="../media/azure-resources-extension.png" alt-text="Screenshot showing the Azure Resources extension.":::
61
+
62
+
1. Open the Command Palette in Visual Studio Code, then search for and select **Azure: Sign in**.
63
+
64
+
:::image type="content" source="../media/visual-studio-code-sign-in.png" alt-text="Screenshot showing how to sign in to Azure in Visual Studio Code.":::
65
+
66
+
> [!TIP]
67
+
> Open the Command Palette using `Ctrl+Shift+P` on Windows/Linux or `Cmd+Shift+P` on macOS.
68
+
69
+
1. Add the [Azure.Identity.Broker](https://www.nuget.org/packages/Azure.Identity.Broker) NuGet package to your app:
70
+
71
+
```dotnetcli
72
+
dotnet add package Azure.Identity.Broker
73
+
```
74
+
47
75
### [Azure CLI](#tab/sign-in-azure-cli)
48
76
49
-
Developers coding outside of an IDE can also use the [Azure CLI](/cli/azure/what-is-azure-cli) to authenticate. Apps using `DefaultAzureCredential` or <xref:Azure.Identity.AzureCliCredential> can then use this account to authenticate app requests when running locally.
77
+
Developers can use [Azure CLI](/cli/azure/what-is-azure-cli) to authenticate. Apps using <xref:Azure.Identity.DefaultAzureCredential> or <xref:Azure.Identity.AzureCliCredential> can then use this account to authenticate app requests.
50
78
51
79
To authenticate with the Azure CLI, run the `az login` command. On a system with a default web browser, the Azure CLI launches the browser to authenticate the user.
Developers coding outside of an IDE can also use the [Azure Developer CLI](/azure/developer/azure-developer-cli/overview) to authenticate. Apps using `DefaultAzureCredential` or <xref:Azure.Identity.AzureDeveloperCliCredential> can then use this account to authenticate app requests when running locally.
93
+
Developers can use [Azure Developer CLI](/azure/developer/azure-developer-cli/overview) to authenticate. Apps using <xref:Azure.Identity.DefaultAzureCredential> or <xref:Azure.Identity.AzureDeveloperCliCredential> can then use this account to authenticate app requests.
66
94
67
95
To authenticate with the Azure Developer CLI, run the `azd auth login` command. On a system with a default web browser, the Azure Developer CLI launches the browser to authenticate the user.
68
96
69
97
```azdeveloper
70
98
azd auth login
71
99
```
72
100
73
-
For systems without a default web browser, the `azd auth login --use-device-code` uses the device code authentication flow. The user can also force the the Azure Developer CLI to use the device code flow rather than launching a browser by specifying the `--use-device-code` argument.
101
+
For systems without a default web browser, the `azd auth login --use-device-code` uses the device code authentication flow. The user can also force the Azure Developer CLI to use the device code flow rather than launching a browser by specifying the `--use-device-code` argument.
Developers coding outside of an IDE can also use [Azure PowerShell](/powershell/azure/what-is-azure-powershell) to authenticate. Apps using `DefaultAzureCredential` or <xref:Azure.Identity.AzurePowerShellCredential> can then use this account to authenticate app requests when running locally.
109
+
Developers can use [Azure PowerShell](/powershell/azure/what-is-azure-powershell) to authenticate. Apps using <xref:Azure.Identity.DefaultAzureCredential> or <xref:Azure.Identity.AzurePowerShellCredential> can then use this account to authenticate app requests.
82
110
83
111
To authenticate with Azure PowerShell, run the command `Connect-AzAccount`. On a system with a default web browser and version 5.0.0 or later of Azure PowerShell, it launches the browser to authenticate the user.
Copy file name to clipboardExpand all lines: docs/azure/sdk/authentication/local-development-service-principal.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ During local development, applications need to authenticate to Azure to access v
21
21
22
22
Using dedicated application service principals allows you to adhere to the principle of least privilege when accessing Azure resources. Permissions are limited to the specific requirements of the app during development, preventing accidental access to Azure resources intended for other apps or services. This approach also helps avoid issues when the app is moved to production by ensuring it isn't over-privileged in the development environment.
23
23
24
-
:::image type="content" source="../media/local-dev-service-principal-overview.png" alt-text="A diagram showing how a local .NET app uses the developer's credentials to connect to Azure by using locally installed development tools.":::
24
+
:::image type="content" source="../media/mermaidjs/local-service-principal-authentication.svg" alt-text="A diagram showing how a local .NET app uses a service principal to connect to Azure resources.":::
25
25
26
26
When the app is registered in Azure, an application service principal is created. For local development:
0 commit comments