Question

Difficulty: MediumRun Containerized Solutions using Azure Container Instances

You need to deploy a containerized application to Azure Container Instances (ACI). The container image is stored in a private Azure Container Registry (ACR). You plan to use a user-assigned managed identity to authenticate to the ACR during the container group creation. You will perform the deployment using a YAML configuration file and the Azure CLI. Once the deployment is complete, you must verify the container startup logs to ensure the application initialized correctly.

Which sequence of actions should you perform?

  1. 1Create a user-assigned managed identity and assign it the AcrPull role on the Azure Container Registry (ACR).
  2. 2Retrieve the resource ID of the user-assigned managed identity.
  3. 3Author a YAML configuration file that defines the container group, referencing the registry credentials and the managed identity resource ID.
  4. 4Deploy the container group by running the az container create command with the --file parameter pointing to the YAML configuration file.
  5. 5Verify the deployment and inspect the container startup logs by running the az container logs command.

Answer

To deploy a container group from a private ACR using a user-assigned managed identity, you must first create the identity and assign it the AcrPull role on the registry. Next, retrieve the resource ID of the managed identity. Use this ID to configure the image registry credentials and identity properties inside the YAML definition file. Then, deploy the container group using the az container create command with the --file parameter. Finally, inspect the startup logs using the az container logs command.
The correct order establishes a logical dependency chain. First, the user-assigned identity must be created and granted the AcrPull role on the ACR to authorize image retrieval. Second, its resource ID must be retrieved so it can be embedded in the deployment manifest. Third, the YAML configuration file must be written to specify the identity and credentials. Fourth, the deployment is executed via the Azure CLI using the --file parameter. Finally, after the containers are running, their logs are inspected to verify initialization.

Step-by-Step Solution

1
Create a user-assigned managed identity and assign it the AcrPull role on the Azure Container Registry (ACR).
A managed identity is provisioned and authorized to pull container images from the registry.
Azure Container Instances requires permission to pull the image from the private registry. Using a user-assigned managed identity is a secure, credential-free method, but it must be created and authorized beforehand.
2
Retrieve the resource ID of the user-assigned managed identity.
You obtain the fully qualified Azure Resource Manager (ARM) ID of the managed identity.
The YAML template configuration requires the exact resource ID of the managed identity to reference it under the identity block and image registry credentials.
3
Author a YAML configuration file that defines the container group, referencing the registry credentials and the managed identity resource ID.
A completed YAML configuration file representing the container group structure and authentication details.
To use a user-assigned managed identity to authenticate to ACR, the relationship must be defined in the YAML file before deployment under the imageRegistryCredentials and identity sections.
4
Deploy the container group by running the az container create command with the --file parameter pointing to the YAML configuration file.
The ACI container group is created and deployed in Azure.
The az container create command applies the YAML configuration to spin up the container group.
5
Verify the deployment and inspect the container startup logs by running the az container logs command.
The stdout/stderr streams of the container are displayed.
Checking the container logs is the final step to confirm the application within the container group started successfully.

Key Concept

Deploying container groups using YAML and authenticating to ACR using a user-assigned managed identity.
Rate this question