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: articles/container-apps/managed-identity.md
+36-33Lines changed: 36 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ A managed identity from Microsoft Entra ID allows your container app to access o
17
17
Your container app can be granted two types of identities:
18
18
19
19
- A **system-assigned identity** is tied to your container app and is deleted when your container app is deleted. An app can only have one system-assigned identity.
20
-
- A **user-assigned identity** is a standalone Azure resource that can be assigned to your container app and other resources. A container app can have multiple user-assigned identities. The identity exists until you delete them.
20
+
- A **user-assigned identity** is a standalone Azure resource that you can assign to your container app and other resources. A container app can have multiple user-assigned identities. User-assigned identities exist until you delete them.
21
21
22
22
## Why use a managed identity?
23
23
@@ -28,9 +28,9 @@ With managed identities:
28
28
- Your app connects to resources with the managed identity. You don't need to manage credentials in your container app.
29
29
- You can use role-based access control to grant specific permissions to a managed identity.
30
30
- System-assigned identities are automatically created and managed. They're deleted when your container app is deleted.
31
-
- You can add and delete user-assigned identities and assign them to multiple resources. They're independent of your container app's life cycle.
32
-
- You can use managed identity to [authenticate with a private Azure Container Registry](./managed-identity-image-pull.md) without a username and password to pull containers for your Container App.
33
-
- You can use [managed identity to create connections for Dapr-enabled applications via Dapr components](./dapr-overview.md)
31
+
- You can add and delete user-assigned identities and assign them to multiple resources. They're independent of your container app's lifecycle.
32
+
- You can use managed identity to [authenticate with a private Azure Container Registry](./managed-identity-image-pull.md) without a username and password to pull containers for your container app.
33
+
- You can use a [managed identity to create connections for Dapr-enabled applications via Dapr components](./dapr-overview.md)
34
34
35
35
### Common use cases
36
36
@@ -46,9 +46,8 @@ User-assigned identities are ideal for workloads that:
46
46
47
47
## Limitations
48
48
49
-
Using managed identities in scale rules isn't supported. You'll still need to include the connection string or key in the `secretRef` of the scaling rule.
@@ -67,11 +66,13 @@ When a managed identity is added, deleted, or modified on a running container ap
67
66
68
67
# [Azure portal](#tab/portal)
69
68
70
-
1. In the left navigation of your container app's page, scroll down to the **Settings** group.
69
+
1. Go to your container app in the Azure portal.
70
+
71
+
1. From the *Settings* group, select **Identity**.
71
72
72
-
1.Select **Identity**.
73
+
1.Within the *System assigned* tab, switch *Status* to **On**.
73
74
74
-
1.Within the **System assigned** tab, switch **Status** to **On**. Select **Save**.
75
+
1. Select **Save**.
75
76
76
77
:::image type="content" source="media/managed-identity/screenshot-system-assigned-identity.png" alt-text="Screenshot of system-assigned identities.":::
77
78
@@ -118,13 +119,15 @@ First, you'll need to create a user-assigned identity resource.
118
119
119
120
1. Create a user-assigned managed identity resource according to the steps found in [Manage user-assigned managed identities](../active-directory/managed-identities-azure-resources/how-to-manage-ua-identity-portal.md#create-a-user-assigned-managed-identity).
120
121
121
-
1. In the left navigation for your container app's page, scroll down to the **Settings** group.
122
+
1. Go to your container app in the Azure portal.
122
123
123
-
1. Select **Identity**.
124
+
1. From the *Settings* group, select **Identity**.
124
125
125
-
1. Within the **User assigned** tab, select **Add**.
126
+
1. Within the *User assigned* tab, select **Add**.
126
127
127
-
1. Search for the identity you created earlier and select it. Select **Add**.
128
+
1. Search for and select the identity you created earlier.
129
+
130
+
1. Select **Add**.
128
131
129
132
:::image type="content" source="media/managed-identity/screenshot-user-assigned-identity.png" alt-text="Screenshot of user-assigned identities.":::
130
133
@@ -166,7 +169,7 @@ Specify each user-assigned identity by adding an item to the `userAssignedIdenti
166
169
For a complete ARM template example, see [ARM API Specification](azure-resource-manager-api-spec.md?tabs=arm-template#container-app-examples).
167
170
168
171
> [!NOTE]
169
-
> An application can have both system-assigned and user-assigned identities at the same time. In this case, the type property would be `SystemAssigned,UserAssigned`.
172
+
> An application can have both system-assigned and user-assigned identities at the same time. In this case, the value for `type` property would be `SystemAssigned,UserAssigned`.
170
173
171
174
# [YAML](#tab/yaml)
172
175
@@ -191,64 +194,64 @@ For a complete YAML template example, see [ARM API Specification](azure-resource
191
194
192
195
## Configure a target resource
193
196
194
-
For some resources, you'll need to configure role assignments for your app's managed identity to grant access. Otherwise, calls from your app to services, such as Azure Key Vault and Azure SQL Database, will be rejected even if you use a valid token for that identity. To learn more about Azure role-based access control (Azure RBAC), see [What is RBAC?](../role-based-access-control/overview.md). To learn more about which resources support Microsoft Entra tokens, see [Azure services that support Microsoft Entra authentication](../active-directory/managed-identities-azure-resources/services-support-managed-identities.md#azure-services-that-support-azure-ad-authentication).
197
+
For some resources, you need to configure role assignments for your app's managed identity to grant access. Otherwise, calls from your app to services, such as Azure Key Vault and Azure SQL Database, are rejected even when you use a valid token for that identity. To learn more about Azure role-based access control (Azure RBAC), see [What is RBAC?](../role-based-access-control/overview.md). To learn more about which resources support Microsoft Entra tokens, see [Azure services that support Microsoft Entra authentication](../active-directory/managed-identities-azure-resources/services-support-managed-identities.md#azure-services-that-support-azure-ad-authentication).
195
198
196
199
> [!IMPORTANT]
197
-
> The back-end services for managed identities maintain a cache per resource URI for around 24 hours. If you update the access policy of a particular target resource and immediately retrieve a token for that resource, you may continue to get a cached token with outdated permissions until that token expires. There's currently no way to force a token refresh.
200
+
> The back-end services for managed identities maintain a cache per resource URI for around 24 hours. If you update the access policy of a particular target resource and immediately retrieve a token for that resource, you may continue to get a cached token with outdated permissions until that token expires. Forcing a token refresh isn't supported.
198
201
199
202
## Connect to Azure services in app code
200
203
201
204
With managed identities, an app can obtain tokens to access Azure resources that use Microsoft Entra ID, such as Azure SQL Database, Azure Key Vault, and Azure Storage. These tokens represent the application accessing the resource, and not any specific user of the application.
202
205
203
-
Container Apps provides an internally accessible [REST endpoint](managed-identity.md?tabs=cli%2Chttp#rest-endpoint-reference) to retrieve tokens. The REST endpoint can be accessed from within the app with a standard HTTP GET, which can be implemented with a generic HTTP client in every language. For .NET, JavaScript, Java, and Python, the Azure Identity client library provides an abstraction over this REST endpoint. Connecting to other Azure services is as simple as adding a credential object to the service-specific client.
206
+
Container Apps provides an internally accessible [REST endpoint](managed-identity.md?tabs=cli%2Chttp#rest-endpoint-reference) to retrieve tokens. The REST endpoint is availasble from within the app with a standard HTTP `GET` request, which you can implement with a generic HTTP client in your preferred language. For .NET, JavaScript, Java, and Python, the Azure Identity client library provides an abstraction over this REST endpoint. You can connect to other Azure services by adding a credential object to the service-specific client.
204
207
205
208
> [!NOTE]
206
-
> When using Azure Identity client library, the user-assigned managed identity client id must be specified.
209
+
> When using Azure Identity client library, you need to explicitly specify the user-assigned managed identity client id.
207
210
208
211
# [.NET](#tab/dotnet)
209
212
210
213
> [!NOTE]
211
-
> When connecting to Azure SQL data sources with [Entity Framework Core](/ef/core/), consider [using Microsoft.Data.SqlClient](/sql/connect/ado-net/sql/azure-active-directory-authentication), which provides special connection strings for managed identity connectivity.
214
+
> When connecting to Azure SQL data sources with [Entity Framework Core](/ef/core/), consider using [Microsoft.Data.SqlClient](/sql/connect/ado-net/sql/azure-active-directory-authentication), which provides special connection strings for managed identity connectivity.
212
215
213
-
For .NET apps, the simplest way to work with a managed identity is through the [Azure Identity client library for .NET](/dotnet/api/overview/azure/identity-readme). See the respective documentation headings of the client library for information:
216
+
For .NET apps, the simplest way to work with a managed identity is through the [Azure Identity client library for .NET](/dotnet/api/overview/azure/identity-readme). See the following resources for more information:
214
217
215
218
- [Add Azure Identity client library to your project](/dotnet/api/overview/azure/identity-readme#getting-started)
216
219
- [Access Azure service with a system-assigned identity](/dotnet/api/overview/azure/identity-readme#authenticating-with-defaultazurecredential)
217
220
- [Access Azure service with a user-assigned identity](/dotnet/api/overview/azure/identity-readme#specify-a-user-assigned-managed-identity-with-defaultazurecredential)
218
221
219
-
The linked examples use [`DefaultAzureCredential`](/dotnet/api/overview/azure/identity-readme#defaultazurecredential). It's useful for most the scenarios because the same pattern works in Azure (with managed identities) and on your local machine (without managed identities).
222
+
The linked examples use [`DefaultAzureCredential`](/dotnet/api/overview/azure/identity-readme#defaultazurecredential). This object is effective in most scenarios as the same pattern works in Azure (with managed identities) and on your local machine (without managed identities).
220
223
221
224
# [JavaScript](#tab/javascript)
222
225
223
-
For Node.js apps, the simplest way to work with a managed identity is through the [Azure Identity client library for JavaScript](/javascript/api/overview/azure/identity-readme?). See the respective documentation headings of the client library for information:
226
+
For Node.js apps, the simplest way to work with a managed identity is through the [Azure Identity client library for JavaScript](/javascript/api/overview/azure/identity-readme?). See the following resources for more information:
224
227
225
228
- [Add Azure Identity client library to your project](/javascript/api/overview/azure/identity-readme#install-the-package)
226
229
- [Access Azure service with a system-assigned identity](/javascript/api/overview/azure/identity-readme#authenticating-with-defaultazurecredential)
227
230
- [Access Azure service with a user-assigned identity](/javascript/api/overview/azure/identity-readme#authenticating-a-user-assigned-managed-identity-with-defaultazurecredential)
228
231
229
-
The linked examples use [`DefaultAzureCredential`](/javascript/api/overview/azure/identity-readme#defaultazurecredential). It's useful for most the scenarios because the same pattern works in Azure (with managed identities) and on your local machine (without managed identities).
232
+
The linked examples use [`DefaultAzureCredential`](/javascript/api/overview/azure/identity-readme#defaultazurecredential). This object is effective in most scenarios as the same pattern works in Azure (with managed identities) and on your local machine (without managed identities).
230
233
231
234
For more code examples of the Azure Identity client library for JavaScript, see [Azure Identity examples](https://github.com/Azure/azure-sdk-for-js/blob/%40azure/identity_2.0.1/sdk/identity/identity/samples/AzureIdentityExamples.md).
232
235
233
236
# [Python](#tab/python)
234
237
235
-
For Python apps, the simplest way to work with a managed identity is through the [Azure Identity client library for Python](/python/api/overview/azure/identity-readme). See the respective documentation headings of the client library for information:
238
+
For Python apps, the simplest way to work with a managed identity is through the [Azure Identity client library for Python](/python/api/overview/azure/identity-readme). See the following resources for more information:
236
239
237
240
- [Add Azure Identity client library to your project](/python/api/overview/azure/identity-readme#getting-started)
238
241
- [Access Azure service with a system-assigned identity](/python/api/overview/azure/identity-readme#authenticating-with-defaultazurecredential)
239
242
- [Access Azure service with a user-assigned identity](/python/api/overview/azure/identity-readme#authenticating-a-user-assigned-managed-identity-with-defaultazurecredential)
240
243
241
-
The linked examples use [`DefaultAzureCredential`](/python/api/overview/azure/identity-readme#defaultazurecredential). It's useful for most the scenarios because the same pattern works in Azure (with managed identities) and on your local machine (without managed identities).
244
+
The linked examples use [`DefaultAzureCredential`](/python/api/overview/azure/identity-readme#defaultazurecredential). This object is effective in most scenarios as the same pattern works in Azure (with managed identities) and on your local machine (without managed identities).
242
245
243
246
# [Java](#tab/java)
244
247
245
-
For Java apps and functions, the simplest way to work with a managed identity is through the [Azure Identity client library for Java](/java/api/overview/azure/identity-readme). See the respective documentation headings of the client library for information:
248
+
For Java apps and functions, the simplest way to work with a managed identity is through the [Azure Identity client library for Java](/java/api/overview/azure/identity-readme). See the following resources for more information:
246
249
247
250
- [Add Azure Identity client library to your project](/java/api/overview/azure/identity-readme#include-the-package)
248
251
- [Access Azure service with a system-assigned identity](/java/api/overview/azure/identity-readme#authenticating-with-defaultazurecredential)
249
252
- [Access Azure service with a user-assigned identity](/java/api/overview/azure/identity-readme#authenticating-a-user-assigned-managed-identity-with-defaultazurecredential)
250
253
251
-
The linked examples use [`DefaultAzureCredential`](/azure/developer/java/sdk/identity-azure-hosted-auth#default-azure-credential). It's useful for most the scenarios because the same pattern works in Azure (with managed identities) and on your local machine (without managed identities).
254
+
The linked examples use [`DefaultAzureCredential`](/azure/developer/java/sdk/identity-azure-hosted-auth#default-azure-credential). This object is effective in most scenarios as the same pattern works in Azure (with managed identities) and on your local machine (without managed identities).
252
255
253
256
For more code examples of the Azure Identity client library for Java, see [Azure Identity Examples](https://github.com/Azure/azure-sdk-for-java/wiki/Azure-Identity-Examples).
A raw HTTP GET request looks like the following example.
271
+
A raw HTTP `GET` request looks like the following example.
269
272
270
273
Obtain the token endpoint URL from the `IDENTITY_ENDPOINT` environment variable. `x-identity-header` contains the GUID that is stored in the `IDENTITY_HEADER` environment variable.
This response is the same as the [response for the Microsoft Entra service-to-service access token request](../active-directory/develop/v2-oauth2-client-creds-grant-flow.md#successful-response). To access Key Vault, you'll then add the value of `access_token` to a client connection with the vault.
296
+
This response is the same as the [response for the Microsoft Entra service-to-service access token request](../active-directory/develop/v2-oauth2-client-creds-grant-flow.md#successful-response). To access Key Vault, add the value of `access_token` to a client connection with the vault.
294
297
295
298
### REST endpoint reference
296
299
297
300
A container app with a managed identity exposes the identity endpoint by defining two environment variables:
298
301
299
-
- `IDENTITY_ENDPOINT`- local URL from which your container app can request tokens.
300
-
- `IDENTITY_HEADER`- a header used to help mitigate server-side request forgery (SSRF) attacks. The value is rotated by the platform.
302
+
- `IDENTITY_ENDPOINT`: Local URL from which your container app can request tokens.
303
+
- `IDENTITY_HEADER`: A header used to help mitigate server-side request forgery (SSRF) attacks. The value is rotated by the platform.
301
304
302
-
To get a token for a resource, make an HTTP GET request to the endpoint, including the following parameters:
305
+
To get a token for a resource, make an HTTP `GET` request to the endpoint, including the following parameters:
0 commit comments