You are deploying a containerized API application to Azure Container Instances (ACI). The container image is stored in a private Azure Container Registry (ACR). The application must retrieve database connection strings from Azure Key Vault at startup.
You want to implement a secure solution that uses managed identities to authenticate both the image pull from ACR and the secret retrieval from Key Vault, avoiding hardcoded credentials.
You attempt to deploy the container group using a system-assigned managed identity, but the deployment fails with an image pull authorization error.
Which of the following actions should you perform to resolve this deployment failure?
- Configure the container group to use a user-assigned managed identity, grant that identity the AcrPull role on the Azure Container Registry, and specify this identity for the registry credentials and container identity.Answer
- BGrant the container group's system-assigned managed identity the AcrPull role on the Azure Container Registry, and configure the registry credentials parameters to reference the system identity.
- CGrant the Azure Container Registry service principal GET permissions in the Azure Key Vault access policy, and reference the registry credentials.
- DAuthenticate to the Azure Container Registry using the Azure CLI on your local machine, and then deploy the container group without specifying credentials.
Answer
Configure the container group to use a user-assigned managed identity, grant that identity the AcrPull role on the Azure Container Registry, and specify this identity for the registry credentials and container identity.
To pull an image from a private Azure Container Registry using a managed identity, you must use a user-assigned managed identity. A system-assigned managed identity cannot be used because it is created concurrently with the container group, meaning it does not exist when the image pull request is initiated. By using a user-assigned identity and assigning it the AcrPull role, Azure Container Instances can successfully authenticate to the registry and pull the image before creating the container.
Step-by-Step Solution
Key Concept
Authentication to Azure Container Registry from Azure Container Instances using a user-assigned managed identity.