You are configuring an Azure Container Registry (ACR) task named `build-task` in a registry named `myregistry`. The task must build a container image from a remote GitHub repository and push it to `myregistry`. The build process requires pulling a private base image from an external Azure Container Registry named `sharedregistry.azurecr.io`.
You create a user-assigned managed identity named `task-identity` and assign it the `AcrPull` role on `sharedregistry.azurecr.io`.
You associate the identity with the task by running the following command:
azurecli
az acr task create \
--registry myregistry \
--name build-task \
--image myimage:latest \
--context https://github.com/myorg/myrepo.git#main \
--file Dockerfile \
--assign-identity /subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/task-identity
When the task executes, the build fails during the base image pull from `sharedregistry.azurecr.io` with an HTTP 401 Unauthorized error.
Which command should you execute to enable the task to authenticate successfully to the external registry?
- az acr task credential add --name build-task --registry myregistry --login-server sharedregistry.azurecr.io --user-assigned-identity 11111111-1111-1111-1111-111111111111Answer
- BAdd a RUN az acr login --name sharedregistry.azurecr.io instruction inside the Dockerfile before the FROM instruction
- Caz acr task update --name build-task --registry myregistry --auth-mode ManagedIdentity
- Daz acr task credential add --name build-task --registry myregistry --login-server sharedregistry.azurecr.io --use-system-assigned