An organization is designing an Azure Resource Manager (ARM) template to deploy a multi-container group to Azure Container Instances (ACI). The deployment must satisfy the following requirements:
- The container group must pull a custom web application image from a private Azure Container Registry (ACR) named `myregistry.azurecr.io`.
- Both containers in the group must retrieve database connection strings from Azure Key Vault at startup without using hardcoded credentials.
- The deployment must utilize managed identities to authenticate against both the ACR and the Key Vault, adhering to the principle of least privilege.
Which configuration strategy should you implement in the template and Azure roles?
- Configure the container group with a user-assigned managed identity. Assign the AcrPull role to this identity on the ACR, and the Key Vault Secrets User role on the Key Vault. In the template, reference this user-assigned managed identity's resource ID in both the identity block and the identity property of the imageRegistryCredentials block.Answer
- BConfigure the container group with a system-assigned managed identity. Assign the AcrPull role to this identity on the ACR, and the Key Vault Secrets User role on the Key Vault. In the template, enable the system-assigned identity in the identity block, and reference it in the identity property of the imageRegistryCredentials block.
- CConfigure the container group with a user-assigned managed identity. Assign the AcrPull role to this identity on the ACR, and reference its resource ID in the identity block and the imageRegistryCredentials block. In the application code, request a token for the user-assigned identity to authenticate to Key Vault, without assigning any RBAC roles or access policies to the identity in Key Vault.
- DConfigure the container group with a user-assigned managed identity. Assign the AcrPull role to this identity on the ACR, and the Key Vault Secrets User role on the Key Vault. Reference the identity's resource ID in the identity block, but omit the imageRegistryCredentials block to allow the container group to authenticate implicitly during the image pull.
Answer
The correct strategy is to configure the container group with a user-assigned managed identity, assign the required roles on the Azure Container Registry (ACR) and Azure Key Vault, and reference the identity's resource ID in both the identity block and the imageRegistryCredentials block.
To pull an image from a private ACR using a managed identity during ACI deployment, a user-assigned managed identity must be used. A system-assigned managed identity is not created until after the container group is deployed, so it cannot be used to authenticate the initial image pull. The user-assigned identity must be assigned the AcrPull role on the ACR and the Key Vault Secrets User role (or equivalent access policy) on the Key Vault. Furthermore, the template must explicitly list the identity in the identity block and refer to its resource ID in the imageRegistryCredentials block.
Step-by-Step Solution
Key Concept
Using a user-assigned managed identity to authenticate both private ACR image pulls and Azure Key Vault secret access in Azure Container Instances.
Estimated Time:3m 0s