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
title: Authorize access to Azure App Configuration using Microsoft Entra ID
2
+
title: Access Azure App Configuration using Microsoft Entra ID
3
3
description: Enable Azure RBAC to authorize access to your Azure App Configuration instance.
4
-
author: maud-lv
5
-
ms.author: malev
6
-
ms.date: 04/05/2024
4
+
author: zhenlan
5
+
ms.author: zhenlwa
6
+
ms.date: 10/05/2024
7
7
ms.topic: conceptual
8
8
ms.service: azure-app-configuration
9
9
10
10
---
11
-
# Authorize access to Azure App Configuration using Microsoft Entra ID
12
-
Besides using Hash-based Message Authentication Code (HMAC), Azure App Configuration supports using Microsoft Entra ID to authorize requests to App Configuration instances. Microsoft Entra ID allows you to use Azure role-based access control (Azure RBAC) to grant permissions to a security principal. A security principal may be a user, a [managed identity](../active-directory/managed-identities-azure-resources/overview.md), or an [application service principal](../active-directory/develop/app-objects-and-service-principals.md). To learn more about roles and role assignments, see [Understanding different roles](../role-based-access-control/overview.md).
11
+
# Access Azure App Configuration using Microsoft Entra ID
12
+
Azure App Configuration supports authorization of requests to App Configuration stores using Microsoft Entra ID. With Microsoft Entra ID, you can leverage Azure role-based access control ([Azure RBAC](../role-based-access-control/overview.md)) to grant permissions to security principals, which can be user principals, [managed identities](../active-directory/managed-identities-azure-resources/overview.md), or [service principals](../active-directory/develop/app-objects-and-service-principals.md).
13
13
14
14
## Overview
15
-
Requests made by a security principal to access an App Configuration resource must be authorized. With Microsoft Entra ID, access to a resource is a two-step process:
16
-
1. The security principal's identity is authenticated and an OAuth 2.0 token is returned. The resource name to request a token is `https://login.microsoftonline.com/{tenantID}` where `{tenantID}` matches the Microsoft Entra tenant ID to which the service principal belongs.
17
-
2. The token is passed as part of a request to the App Configuration service to authorize access to the specified resource.
15
+
Accessing an App Configuration store using Microsoft Entra ID involves two steps:
18
16
19
-
The authentication step requires that an application request contains an OAuth 2.0 access token at runtime. If an application is running within an Azure entity, such as an Azure Functions app, an Azure Web App, or an Azure VM, it can use a managed identity to access the resources. To learn how to authenticate requests made by a managed identity to Azure App Configuration, see [Authenticate access to Azure App Configuration resources with Microsoft Entra ID and managed identities for Azure Resources](howto-integrate-azure-managed-service-identity.md).
17
+
1.**Authentication**: Acquire a token of the security principal from Microsoft Entra ID for App Configuration. For more details, see [Microsoft Entra authentication](./rest-api-authentication-azure-ad.md) in App Configuration.
20
18
21
-
The authorization step requires that one or more Azure roles be assigned to the security principal. Azure App Configuration provides Azure roles that encompass sets of permissions for App Configuration resources. The roles that are assigned to a security principal determine the permissions provided to the principal. For more information about Azure roles, see [Azure built-in roles for Azure App Configuration](#azure-built-in-roles-for-azure-app-configuration).
22
-
23
-
## Assign Azure roles for access rights
24
-
Microsoft Entra authorizes access rights to secured resources through [Azure role-based access control (Azure RBAC)](../role-based-access-control/overview.md).
25
-
26
-
When an Azure role is assigned to a Microsoft Entra security principal, Azure grants access to those resources for that security principal. Access is scoped to the App Configuration resource. A Microsoft Entra security principal may be a user, a group, an application service principal, or a [managed identity for Azure resources](../active-directory/managed-identities-azure-resources/overview.md).
19
+
1.**Authorization**: Pass the token as part of a request to an App Configuration store. To authorize access to the specified App Configuration store, the serurity principal must be assigned the appropriate roles in advance. For more information, see [Microsoft Entra authorization](./rest-api-authorization-azure-ad.md) in App Configuration.
27
20
28
21
## Azure built-in roles for Azure App Configuration
29
-
Azure provides the following Azure built-in roles for authorizing access to App Configuration data using Microsoft Entra ID:
22
+
Azure provides the following built-in roles for authorizing access to App Configuration using Microsoft Entra ID:
30
23
31
-
-**App Configuration Data Owner**: Use this role to give read/write/delete access to App Configuration data. This role doesn't grant access to the App Configuration resource.
24
+
### Data plane access
25
+
Requests for [data plane](../azure-resource-manager/management/control-plane-and-data-plane.md#data-plane) operations are sent to the endpoint of your App Configuration store. These requests pertain to App Configuration data.
26
+
27
+
-**App Configuration Data Owner**: Use this role to give read, write, and delete access to App Configuration data. This role doesn't grant access to the App Configuration resource.
32
28
-**App Configuration Data Reader**: Use this role to give read access to App Configuration data. This role doesn't grant access to the App Configuration resource.
33
-
-**Contributor** or **Owner**: Use this role to manage the App Configuration resource. It grants access to the resource's access keys. While the App Configuration data can be accessed using access keys, this role doesn't grant direct access to the data using Microsoft Entra ID. This role is required if you access the App Configuration data via ARM template, Bicep, or Terraform during deployment. For more information, see [deployment](quickstart-deployment-overview.md).
29
+
30
+
### Control plane access
31
+
All requests for [control plane](../azure-resource-manager/management/control-plane-and-data-plane.md#control-plane) operations are sent to the Azure Resource Manager URL. These requests pertain to the App Configuration resource.
32
+
33
+
-**Contributor** or **Owner**: Use this role to manage the App Configuration resource. It grants access to the resource's access keys. While the App Configuration data can be accessed using access keys, this role doesn't grant direct access to the data using Microsoft Entra ID.
34
34
-**Reader**: Use this role to give read access to the App Configuration resource. This role doesn't grant access to the resource's access keys, nor to the data stored in App Configuration.
35
35
36
36
> [!NOTE]
37
37
> After a role assignment is made for an identity, allow up to 15 minutes for the permission to propagate before accessing data stored in App Configuration using this identity.
38
38
39
+
## Authentication with Token Credentials
40
+
41
+
To enable your application to authenticate with Microsoft Entra ID, the Azure Identity library supports various token credentials for Microsoft Entra ID authentication. For example, you might choose Visual Studio Credential when developing your application in Visual Studio, Workload Identity Credential when your application runs on Kubernetes, or Managed Identity Credential when your application is deployed in Azure services like Azure Functions.
42
+
43
+
### Use DefaultAzureCredential
44
+
45
+
The `DefaultAzureCredential` is a preconfigured [chain of token credentials](/dotnet/azure/sdk/authentication/credential-chains.md#defaultazurecredential-overview) that automatically attempts an ordered sequence of the most common authentication methods. Using the `DefaultAzureCredential` allows you to keep the same code in both local development and Azure environments. However, it's important to know which credential is being used in each environment, as you need to grant the appropriate roles for authorization to work. For example, authorize your own account when you expect the `DefaultAzureCredential` to fall back to your user identity during local development. Similarly, enable managed identity in Azure Functions and assign it the necessary role when you expect the `DefaultAzureCredential` to fall back to the `ManagedIdentityCredential` when your Function App runs in Azure.
46
+
47
+
### Assign App Configuration Data Roles
48
+
49
+
Regardless of which credential you use, you must assign it the appropriate roles before it can access your App Configuration store. If your application only needs to read data from your App Configuration store, assign it the *App Configuration Data Reader* role. If your application also needs to write data to your App Configuration store, assign it the *App Configuration Data Owner* role.
50
+
51
+
Follow these steps to assign App Configuration Data roles to your credential.
52
+
53
+
1. In the Azure portal, navigate to your App Configuration store and select **Access control (IAM)**.
54
+
1. Select **Add** -> **Add role assignment**.
55
+
56
+
If you don't have permission to assign roles, the **Add role assignment** option will be disabled. Only users with *Owner* or *User Access Administrator* roles can make role assignments.
57
+
2. On the **Role** tab, select the **App Configuration Data Reader** role (or another App Configuration role as appropriate) and then select **Next**.
58
+
3. On the **Members** tab, follow the wizard to select the credential you are granting access to and then select **Next**.
59
+
4. Finally, on the **Review + assign** tab, select **Review + assign** to assign the role.
60
+
39
61
## Next steps
40
-
Learn more about using [managed identities](howto-integrate-azure-managed-service-identity.md) to administer your App Configuration service.
62
+
Learn how to [use managed identities to access your App Configuration store](howto-integrate-azure-managed-service-identity.md).
1. Run the following command to restore packages for your project:
53
63
54
64
```dotnetcli
55
65
dotnet restore
56
66
```
57
67
58
-
1. Open *Program.cs*, and add the following statements:
68
+
1. Open the *Program.cs* file, and add the following namespaces:
69
+
59
70
71
+
### [Microsoft Entra ID](#tab/entra-id)
60
72
```csharp
61
73
using Microsoft.Extensions.Configuration;
62
74
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
75
+
using Azure.Identity;
63
76
```
64
77
65
-
1. Use App Configuration by calling the `AddAzureAppConfiguration` method in the `Program.cs` file.
78
+
### [Connection string](#tab/connection-string)
79
+
```csharp
80
+
using Microsoft.Extensions.Configuration;
81
+
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
82
+
```
83
+
---
84
+
85
+
1. Connect to your App Configuration store by calling the `AddAzureAppConfiguration` method in the `Program.cs` file.
86
+
87
+
### [Microsoft Entra ID](#tab/entra-id)
88
+
You can use any token credentials to authenticate to your App Configuration store as appropriate. In this example, you use the `DefaultAzureCredential`. Follow the [instructions](./concept-enable-rbac.md#authentication-with-token-credentials) to assign your credential the **App Configuration Data Reader** role and allow sufficient time for the permission to propagate before running your application.
1. Set an environment variable named **ConnectionString**, and set it to the access key to your App Configuration store. At the command line, run the following command:
Set the environment variable named **Endpoint** to the endpoint of your App Configuration store found under the *Overview* of your store in the Azure portal.
80
118
81
-
To build and run the app locally using the Windows command prompt, run the following command:
119
+
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
Set the environment variable named **ConnectionString** to the read-only connection string of your App Configuration store found under *Access keys* of your store in the Azure portal.
98
139
99
-
If you use macOS, run the following command:
140
+
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
0 commit comments