Skip to content

Commit 8f2aae8

Browse files
authored
Add managed identity info
1 parent d87541a commit 8f2aae8

File tree

1 file changed

+124
-1
lines changed

1 file changed

+124
-1
lines changed

articles/container-apps/sessions-custom-container.md

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Before you send the request, replace the placeholders between the `<>` brackets
107107
```json
108108
{
109109
"type": "Microsoft.App/sessionPools",
110-
"apiVersion": "2024-02-02-preview",
110+
"apiVersion": "2024-08-02-preview",
111111
"name": "my-session-pool",
112112
"location": "westus2",
113113
"properties": {
@@ -122,7 +122,18 @@ Before you send the request, replace the placeholders between the `<>` brackets
122122
"executionType": "Timed",
123123
"cooldownPeriodInSeconds": 600
124124
},
125+
"secrets": [
126+
{
127+
"name": "registrypassword",
128+
"value": "<REGISTRY_PASSWORD>"
129+
}
130+
],
125131
"customContainerTemplate": {
132+
"registryCredentials": {
133+
"server": "myregistry.azurecr.io",
134+
"username": "myregistry",
135+
"passwordSecretRef": "registrypassword"
136+
},
126137
"containers": [
127138
{
128139
"image": "myregistry.azurecr.io/my-container-image:1.0",
@@ -174,6 +185,10 @@ This template creates a session pool with the following settings:
174185
| `scaleConfiguration.readySessionInstances` | `5` | The target number of sessions that are ready in the session pool all the time. Increase this number if sessions are allocated faster than the pool is being replenished. |
175186
| `dynamicPoolConfiguration.executionType` | `Timed` | The type of execution for the session pool. Must be `Timed` for custom container sessions. |
176187
| `dynamicPoolConfiguration.cooldownPeriodInSeconds` | `600` | The number of seconds that a session can be idle before the session is terminated. The idle period is reset each time the session's API is called. Value must be between `300` and `3600`. |
188+
| `secrets` | `[{ "name": "registrypassword", "value": "<REGISTRY_PASSWORD>" }]` | A list of secrets. |
189+
| `customContainerTemplate.registryCredentials.server` | `myregistry.azurecr.io` | The container registry server hostname. |
190+
| `customContainerTemplate.registryCredentials.username` | `myregistry` | The username to log in to the container registry. |
191+
| `customContainerTemplate.registryCredentials.passwordSecretRef` | `registrypassword` | The name of the secret that contains the password to log in to the container registry. |
177192
| `customContainerTemplate.containers[0].image` | `myregistry.azurecr.io/my-container-image:1.0` | The container image to use for the session pool. |
178193
| `customContainerTemplate.containers[0].name` | `mycontainer` | The name of the container. |
179194
| `customContainerTemplate.containers[0].resources.cpu` | `0.25` | The required CPU in cores. |
@@ -240,6 +255,114 @@ This request is forwarded to the custom container session with the identifier fo
240255

241256
In the example, the session's container receives the request at `http://0.0.0.0:<INGRESS_PORT>/<API_PATH_EXPOSED_BY_CONTAINER>`.
242257

258+
### Using managed identity
259+
260+
A managed identity from Microsoft Entra ID allows your custom container session pools and their sessions to access other Microsoft Entra protected resources. For more about managed identities in Microsoft Entra ID, see [Managed identities for Azure resources](../active-directory/managed-identities-azure-resources/overview.md).
261+
262+
You can enable managed identities for your custom container session pools. Both system-assigned and user-assigned managed identities are supported.
263+
264+
There are two ways to use managed identities with custom container session pools:
265+
266+
* **Image pull authentication**: Use the managed identity to authenticate with the container registry to pull the container image.
267+
268+
* **Resource access**: Use the session pool's managed identity in a session to access other Microsoft Entra protected resources. This is off by default.
269+
270+
> [!IMPORTANT]
271+
> If you enable access to the managed identity in a session, any code or programs running in the session can access the pool's managed identity. Because sessions typically run untrusted code, it's recommended to use this feature with caution.
272+
273+
# [Azure CLI](#tab/azure-cli)
274+
275+
To enable managed identity for a custom container session pool, use Azure Resource Manager.
276+
277+
# [Azure Resource Manager](#tab/arm)
278+
279+
To enable managed identity for a custom container session pool, add an `identity` property to the session pool resource. The `identity` property must have a `type` property with the value `SystemAssigned` or `UserAssigned`. For details on how to configure this property, see [Configure managed identities](managed-identity.md?tabs=arm%2Cdotnet#configure-managed-identities).
280+
281+
The following example shows an ARM template snippet that enables a user-assigned identity for a custom container session pool and use it for image pull authentication. Before you send the request, replace the placeholders between the `<>` brackets with the appropriate values for your session pool and session identifier.
282+
283+
```json
284+
{
285+
"type": "Microsoft.App/sessionPools",
286+
"apiVersion": "2024-08-02-preview",
287+
"name": "my-session-pool",
288+
"location": "westus2",
289+
"properties": {
290+
"environmentId": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.ContainerApps/environments/<ENVIRONMENT_NAME>",
291+
"poolManagementType": "Dynamic",
292+
"containerType": "CustomContainer",
293+
"scaleConfiguration": {
294+
"maxConcurrentSessions": 10,
295+
"readySessionInstances": 5
296+
},
297+
"dynamicPoolConfiguration": {
298+
"executionType": "Timed",
299+
"cooldownPeriodInSeconds": 600
300+
},
301+
"customContainerTemplate": {
302+
"registryCredentials": {
303+
"server": "myregistry.azurecr.io",
304+
"identity": "<IDENTITY_RESOURCE_ID>"
305+
},
306+
"containers": [
307+
{
308+
"image": "myregistry.azurecr.io/my-container-image:1.0",
309+
"name": "mycontainer",
310+
"resources": {
311+
"cpu": 0.25,
312+
"memory": "0.5Gi"
313+
},
314+
"command": [
315+
"/bin/sh"
316+
],
317+
"args": [
318+
"-c",
319+
"while true; do echo hello; sleep 10;done"
320+
],
321+
"env": [
322+
{
323+
"name": "key1",
324+
"value": "value1"
325+
},
326+
{
327+
"name": "key2",
328+
"value": "value2"
329+
}
330+
]
331+
}
332+
],
333+
"ingress": {
334+
"targetPort": 80
335+
}
336+
},
337+
"sessionNetworkConfiguration": {
338+
"status": "EgressEnabled"
339+
},
340+
"managedIdentitySettings": [
341+
{
342+
"identity": "<IDENTITY_RESOURCE_ID>",
343+
"lifecycle": "None"
344+
}
345+
]
346+
},
347+
"identity": {
348+
"type": "UserAssigned",
349+
"userAssignedIdentities": {
350+
"<IDENTITY_RESOURCE_ID>": {}
351+
}
352+
}
353+
}
354+
```
355+
356+
This template contains the following additional settings for managed identity:
357+
358+
| Parameter | Value | Description |
359+
|---------|-------|-------------|
360+
| `customContainerTemplate.registryCredentials.identity` | `<IDENTITY_RESOURCE_ID>` | The resource ID of the managed identity to use for image pull authentication. |
361+
| `managedIdentitySettings.identity` | `<IDENTITY_RESOURCE_ID>` | The resource ID of the managed identity to use in the session. |
362+
| `managedIdentitySettings.lifecycle` | `None` | The session lifecycle where the managed identity is available.<br><br>- `None` (default): The session can't access the identity. It's only used for image pull.<br><br>- `Main`: The main session can access the identity. It can also be used for image pull. **Use with caution.** |
363+
364+
---
365+
243366
## Billing
244367

245368
Custom container sessions are billed based on the resources consumed by the session pool. For more information, see [Azure Container Apps billing](billing.md#custom-container).

0 commit comments

Comments
 (0)