Question

Difficulty: HardManage Container Images in Azure Container Registry

Your company uses an Azure Container Registry (ACR) named prodacr. You have created an ACR Task named build-app in prodacr that is configured to build an application image whenever the base image, which resides in a separate private ACR named sharedacr, is updated. You create a user-assigned managed identity named task-identity, assign it to the build-app task, and grant it the AcrPull role on sharedacr. Which command must you run to configure the task to use the user-assigned managed identity when pulling the base image from sharedacr?

  1. az acr task credential add --name build-app --registry prodacr --login-server sharedacr.azurecr.io --use-identity <client-id>Answer
  2. B
    az acr task credential add --name build-app --registry prodacr --login-server sharedacr.azurecr.io --use-identity [system]
  3. C
    az acr login --name sharedacr.azurecr.io --identity
  4. D
    az acr task credential add --name build-app --registry prodacr --login-server sharedacr.azurecr.io --username <client-id> --password <client-secret>

Answer

Execute the 'az acr task credential add' command, specifying the task name, target registry, login server of the source registry, and the '--use-identity' parameter with the client ID of the user-assigned managed identity.
To authenticate an Azure Container Registry (ACR) Task to another private registry using a user-assigned managed identity, you must run the 'az acr task credential add' command. This command configures the specific login server credentials for the task. The '--use-identity' parameter must be set to the client ID of the user-assigned managed identity to ensure that the task uses the identity that has the AcrPull permission on the source registry.

Step-by-Step Solution

1
Identify the authentication requirements for the cross-registry pull within the ACR Task.
The task needs to authenticate to 'sharedacr.azurecr.io' using the user-assigned managed identity 'task-identity' which has been granted 'AcrPull' permissions.
Cross-registry pulls by ACR Tasks require explicit credential registration.
2
Select the correct command for adding credentials to an ACR Task.
The 'az acr task credential add' command is the standard CLI command to associate registry credentials with a specific task.
This command stores registry-specific credentials within the task metadata.
3
Configure the command parameters to use the user-assigned managed identity.
Specify the '--use-identity' parameter followed by the Client ID of the identity, and set the '--login-server' to 'sharedacr.azurecr.io'.
Passing the Client ID tells Azure Container Registry to use that specific user-assigned identity, whereas '[system]' would erroneously trigger system-assigned identity lookup.

Key Concept

Configuring credentials and managed identities for Azure Container Registry Tasks to perform cross-registry image pulls.
Estimated Time:2m 0s
Rate this question