You are configuring a deployment workflow on an Azure Virtual Machine (VM). The VM must build a container image locally and push it to a private Azure Container Registry (ACR) named gridregistry. You have created a User-Assigned Managed Identity named acr-pusher-identity and assigned it the AcrPush role on gridregistry. The VM is configured to use this identity. From the VM's command-line interface, you need to authenticate to Azure and push the local image app:v1 to the registry using the user-assigned managed identity. Which command sequence should you execute?
- az login --identity --username <client_id_of_acr-pusher-identity>
az acr login --name gridregistry
docker tag app:v1 gridregistry.azurecr.io/app:v1
docker push gridregistry.azurecr.io/app:v1Answer - Baz login --identity
az acr login --name gridregistry
docker tag app:v1 gridregistry.azurecr.io/app:v1
docker push gridregistry.azurecr.io/app:v1 - Caz login --identity --username <client_id_of_acr-pusher-identity>
az acr login --name gridregistry.azurecr.io
docker tag app:v1 gridregistry.azurecr.io/app:v1
docker push gridregistry.azurecr.io/app:v1 - Daz login --identity --username <client_id_of_acr-pusher-identity>
az acr login --name gridregistry
docker tag app:v1 gridregistry/app:v1
docker push gridregistry/app:v1
Answer
Execute the sequence that logs in using the user-assigned identity's client ID, logs into the registry using the name 'gridregistry', tags the image with the login server 'gridregistry.azurecr.io/app:v1', and pushes the image.
The correct command sequence first authenticates the Azure CLI with the VM's user-assigned managed identity by explicitly passing the client ID via the --username parameter. It then logs in to the registry using the short name 'gridregistry'. Finally, it tags the image with the registry's fully qualified login server domain 'gridregistry.azurecr.io' and pushes it to the registry.
Step-by-Step Solution
Key Concept
Azure Container Registry authentication and image pushing using a User-Assigned Managed Identity from an Azure VM.