Skip to content

Commit 9e81a5f

Browse files
Merge pull request #277206 from jcjiang/patch-1
Update scale-app.md
2 parents 00cb987 + 003d9d0 commit 9e81a5f

File tree

2 files changed

+82
-22
lines changed

2 files changed

+82
-22
lines changed

articles/container-apps/managed-identity.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,16 @@ To get a token for a resource, make an HTTP `GET` request to the endpoint, inclu
350350

351351
---
352352

353-
## Use managed identity for scale rules
353+
## <a name="scale-rules"></a>Use managed identity for scale rules
354354

355-
Starting in API version `2024-02-02-preview`, you can use managed identities in your scale rules to authenticate with Azure services that support managed identities. To use a managed identity in your scale rule, use the `identity` property instead of the `auth` property in your scale rule. Acceptable values for the `identity` property are either the Azure resource ID of a user-assigned identity, or `system` to use a system-assigned identity
355+
You can use managed identities in your scale rules to authenticate with Azure services that support managed identities. To use a managed identity in your scale rule, use the `identity` property instead of the `auth` property in your scale rule. Acceptable values for the `identity` property are either the Azure resource ID of a user-assigned identity, or `system` to use a system-assigned identity.
356356

357-
The following example shows how to use a managed identities with an Azure Queue Storage scale rule. The queue storage account uses the `accountName` property to identify the storage account, while the `identity` property specifies which managed identity to use. You do not need to use the `auth` property.
357+
> [!NOTE]
358+
> Managed identity authentication in scale rules is in public preview. It's available in API version `2024-02-02-preview`.
359+
360+
The following ARM template example shows how to use a managed identity with an Azure Queue Storage scale rule:
361+
362+
The queue storage account uses the `accountName` property to identify the storage account, while the `identity` property specifies which managed identity to use. You do not need to use the `auth` property.
358363

359364
```json
360365
"scale": {
@@ -371,19 +376,20 @@ The following example shows how to use a managed identities with an Azure Queue
371376
}]
372377
}
373378
```
379+
To learn more about using managed identity with scale rules, see [Set scaling rules in Azure Container Apps](scale-app.md?pivots=azure-portal#authentication-2).
374380

375381
## Control managed identity availability
376382

377-
Container Apps allow you to specify [init containers](containers.md#init-containers) and main containers. By default, both main and init containers in a consumption workload profile environment can use managed identity to access other Azure services. In consumption-only environments and dedicated workload profile environments, only main containers can use managed identity. Managed identity access tokens are available for every managed identity configured on the container app. However, in some situations only the init container or the main container require access tokens for a managed identity. Other times, you may use a managed identity only to access your Azure Container Registry to pull the container image, and your application itself doesn't need to have access to your Azure Container Registry.
383+
Container Apps allows you to specify [init containers](containers.md#init-containers) and main containers. By default, both main and init containers in a consumption workload profile environment can use managed identity to access other Azure services. In consumption-only environments and dedicated workload profile environments, only main containers can use managed identity. Managed identity access tokens are available for every managed identity configured on the container app. However, in some situations only the init container or the main container require access tokens for a managed identity. Other times, you may use a managed identity only to access your Azure Container Registry to pull the container image, and your application itself doesn't need to have access to your Azure Container Registry.
378384

379385
Starting in API version `2024-02-02-preview`, you can control which managed identities are available to your container app during the init and main phases to follow the security principle of least privilege. The following options are available:
380386

381-
- `Init`: available only to init containers. Use this when you want to perform some intilization work that requires a managed identity, but you no longer need the managed identity in the main container. This option is currently only supported in [workload profile consumption environments](environment.md#types)
382-
- `Main`: available only to main containers. Use this if your init container does not need managed identity.
383-
- `All`: available to all containers. This is the default setting.
384-
- `None`: not available to any containers. Use this when you have a managed identity that is only used for ACR image pull, scale rules, or Key Vault secrets and does not need to be available to the code running in your containers.
387+
- `Init`: Available only to init containers. Use this when you want to perform some initialization work that requires a managed identity, but you no longer need the managed identity in the main container. This option is currently only supported in [workload profile consumption environments](environment.md#types)
388+
- `Main`: Available only to main containers. Use this if your init container does not need managed identity.
389+
- `All`: Available to all containers. This value is the default setting.
390+
- `None`: Not available to any containers. Use this when you have a managed identity that is only used for ACR image pull, scale rules, or Key Vault secrets and does not need to be available to the code running in your containers.
385391

386-
The following example shows how to configure a container app on a workload profile consumption environment that:
392+
The following ARM template example shows how to configure a container app on a workload profile consumption environment that:
387393

388394
- Restricts the container app's system-assigned identity to main containers only.
389395
- Restricts a specific user-assigned identity to init containers only.
@@ -413,15 +419,15 @@ This approach limits the resources that can be accessed if a malicious actor wer
413419
"identitySettings":[
414420
{
415421
"identity": "ACR_IMAGEPULL_IDENTITY_RESOURCE_ID",
416-
"lifecycle": "none"
422+
"lifecycle": "None"
417423
},
418424
{
419425
"identity": "<IDENTITY1_RESOURCE_ID>",
420-
"lifecycle": "init"
426+
"lifecycle": "Init"
421427
},
422428
{
423429
"identity": "system",
424-
"lifecycle": "main"
430+
"lifecycle": "Main"
425431
}]
426432
},
427433
"template": {

articles/container-apps/scale-app.md

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ The following example demonstrates how to create a custom scale rule.
247247

248248
This example shows how to convert an [Azure Service Bus scaler](https://keda.sh/docs/latest/scalers/azure-service-bus/) to a Container Apps scale rule, but you use the same process for any other [ScaledObject](https://keda.sh/docs/latest/concepts/scaling-deployments/)-based [KEDA scaler](https://keda.sh/docs/latest/scalers/) specification.
249249

250-
For authentication, KEDA scaler authentication parameters convert into [Container Apps secrets](manage-secrets.md).
250+
For authentication, KEDA scaler authentication parameters take [Container Apps secrets](manage-secrets.md) or [managed identity](managed-identity.md#scale-rules).
251251

252252
::: zone pivot="azure-resource-manager"
253253

@@ -319,10 +319,13 @@ First, you define the type and metadata of the scale rule.
319319

320320
### Authentication
321321

322-
A KEDA scaler supports using secrets in a [TriggerAuthentication](https://keda.sh/docs/latest/concepts/authentication/) that is referenced by the `authenticationRef` property. You can map the TriggerAuthentication object to the Container Apps scale rule.
322+
Container Apps scale rules support secrets-based authentication. Scale rules for Azure resources, including Azure Queue Storage, Azure Service Bus, and Azure Event Hubs, also support managed identity. Where possible, use managed identity authentication to avoid storing secrets within the app.
323323

324-
> [!NOTE]
325-
> Container Apps scale rules only support secret references. Other authentication types such as pod identity are not supported.
324+
#### Use secrets
325+
326+
To use secrets for authentication, you need to create a secret in the container app's `secrets` array. The secret value is used in the `auth` array of the scale rule.
327+
328+
KEDA scalers can use secrets in a [TriggerAuthentication](https://keda.sh/docs/latest/concepts/authentication/) that is referenced by the `authenticationRef` property. You can map the TriggerAuthentication object to the Container Apps scale rule.
326329

327330
1. Find the `TriggerAuthentication` object referenced by the KEDA `ScaledObject` specification.
328331

@@ -344,6 +347,33 @@ A KEDA scaler supports using secrets in a [TriggerAuthentication](https://keda.s
344347

345348
Refer to the [considerations section](#considerations) for more security related information.
346349

350+
#### Using managed identity
351+
352+
Container Apps scale rules can use managed identity to authenticate with Azure services. The following ARM template passes in system-based managed identity to authenticate for an Azure Queue scaler.
353+
354+
```
355+
"scale": {
356+
"minReplicas": 0,
357+
"maxReplicas": 4,
358+
"rules": [
359+
{
360+
"name": "azure-queue",
361+
"custom": {
362+
"type": "azure-queue",
363+
"metadata": {
364+
"accountName": "apptest123",
365+
"queueName": "queue1",
366+
"queueLength": "1"
367+
},
368+
"identity": "system"
369+
}
370+
}
371+
]
372+
}
373+
```
374+
375+
To learn more about using managed identity with scale rules, see [Managed identity](managed-identity.md#scale-rules).
376+
347377
::: zone-end
348378

349379
::: zone pivot="azure-cli"
@@ -368,10 +398,13 @@ A KEDA scaler supports using secrets in a [TriggerAuthentication](https://keda.s
368398

369399
### Authentication
370400

371-
A KEDA scaler supports using secrets in a [TriggerAuthentication](https://keda.sh/docs/latest/concepts/authentication/) that is referenced by the authenticationRef property. You can map the TriggerAuthentication object to the Container Apps scale rule.
401+
Container Apps scale rules support secrets-based authentication. Scale rules for Azure resources, including Azure Queue Storage, Azure Service Bus, and Azure Event Hubs, also support managed identity. Where possible, use managed identity authentication to avoid storing secrets within the app.
372402

373-
> [!NOTE]
374-
> Container Apps scale rules only support secret references. Other authentication types such as pod identity are not supported.
403+
#### Use secrets
404+
405+
To configure secrets-based authentication for a Container Apps scale rule, you configure the secrets in the container app and reference them in the scale rule.
406+
407+
A KEDA scaler supports secrets in a [TriggerAuthentication](https://keda.sh/docs/latest/concepts/authentication/) which the `authenticationRef` property uses for reference. You can map the `TriggerAuthentication` object to the Container Apps scale rule.
375408

376409
1. Find the `TriggerAuthentication` object referenced by the KEDA `ScaledObject` specification. Identify each `secretTargetRef` of the `TriggerAuthentication` object.
377410

@@ -386,6 +419,24 @@ A KEDA scaler supports using secrets in a [TriggerAuthentication](https://keda.s
386419
1. Create an authentication entry with the `--scale-rule-auth` parameter. If there are multiple entries, separate them with a space.
387420

388421
:::code language="bash" source="~/azure-docs-snippets-pr/container-apps/container-apps-azure-service-bus-cli.bash" highlight="8,14":::
422+
423+
#### Using managed identity
424+
425+
Container Apps scale rules can use managed identity to authenticate with Azure services. The following command creates a container app with a user-assigned managed identity and uses it to authenticate for an Azure Queue scaler.
426+
427+
```bash
428+
az containerapp create \
429+
--resource-group <RESOURCE_GROUP> \
430+
--name <APP_NAME> \
431+
--environment <ENVIRONMENT_ID> \
432+
--user-assigned <USER_ASSIGNED_IDENTITY_ID> \
433+
--scale-rule-name azure-queue \
434+
--scale-rule-type azure-queue \
435+
--scale-rule-metadata "accountName=<AZURE_STORAGE_ACCOUNT_NAME>" "queueName=queue1" "queueLength=1" \
436+
--scale-rule-identity <USER_ASSIGNED_IDENTITY_ID>
437+
```
438+
439+
Replace placeholders with your values.
389440

390441
::: zone-end
391442

@@ -423,10 +474,9 @@ A KEDA scaler supports using secrets in a [TriggerAuthentication](https://keda.s
423474

424475
### Authentication
425476

426-
A KEDA scaler supports using secrets in a [TriggerAuthentication](https://keda.sh/docs/latest/concepts/authentication/) that is referenced by the authenticationRef property. You can map the TriggerAuthentication object to the Container Apps scale rule.
477+
Container Apps scale rules support secrets-based authentication. Scale rules for Azure resources, including Azure Queue Storage, Azure Service Bus, and Azure Event Hubs, also support managed identity. Where possible, use managed identity authentication to avoid storing secrets within the app.
427478

428-
> [!NOTE]
429-
> Container Apps scale rules only support secret references. Other authentication types such as pod identity are not supported.
479+
#### Use secrets
430480

431481
1. In your container app, create the [secrets](./manage-secrets.md) that you want to reference.
432482

@@ -436,6 +486,10 @@ A KEDA scaler supports using secrets in a [TriggerAuthentication](https://keda.s
436486

437487
1. In the *Authentication* section, select **Add** to create an entry for each KEDA `secretTargetRef` parameter.
438488

489+
#### Using managed identity
490+
491+
Managed identity authentication is not supported in the Azure portal. Use the [Azure CLI](scale-app.md?pivots=azure-cli#authentication) or [Azure Resource Manager](scale-app.md?&pivots=azure-resource-manager#authentication) to authenticate using managed identity.
492+
439493
::: zone-end
440494

441495
## Default scale rule

0 commit comments

Comments
 (0)