You are deploying a containerized application to Azure Container Apps. The container image is hosted in a private Azure Container Registry (ACR) named myregistry.azurecr.io. You have created a user-assigned managed identity named identity-aca in the resource group rg-prod, and the identity has already been granted the AcrPull role on the registry. You need to configure an existing Container App named api-service in the same resource group to use this user-assigned managed identity to authenticate and pull the image from the registry. Which two of the following Azure CLI commands should you run to complete the configuration? (Select TWO.)
- az containerapp identity assign -n api-service -g rg-prod --user-assigned "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-prod/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-aca"Answer
- az containerapp registry set -n api-service -g rg-prod --server myregistry.azurecr.io --identity "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-prod/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-aca"Answer
- Caz containerapp identity assign -n api-service -g rg-prod --system-assigned
- Daz containerapp registry set -n api-service -g rg-prod --server myregistry.azurecr.io --username "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-prod/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-aca"
Answer
To configure the Container App to pull images from the private registry using the user-assigned identity, you must first assign the user-assigned identity using the 'az containerapp identity assign' command with the '--user-assigned' parameter. Afterward, you must configure the registry settings using 'az containerapp registry set' with the '--identity' parameter specifying the user-assigned identity's resource ID.
Configuring registry access via a user-assigned managed identity requires two CLI steps: assigning the identity's resource ID to the Container App using the 'az containerapp identity assign' command, and setting the registry authentication behavior using 'az containerapp registry set' with the '--identity' parameter specifying the identity's resource ID.
Step-by-Step Solution
Key Concept
Configuring Azure Container App registry authentication using user-assigned managed identities.