You are setting up a secure continuous integration (CI) pipeline to build and publish container images to an Azure Container Registry (ACR) named `acr2026`.
The pipeline must authenticate using an Azure Active Directory service principal named `sp-pipeline`. The service principal has just been created and has no permissions assigned.
You need to configure permissions, authenticate the pipeline runner, build a local image, and upload the image.
In which order should you perform the steps? To answer, arrange the actions in the correct sequence.
- 1Assign the AcrPush role to the service principal for the acr2026 registry resource.
- 2Run docker login acr2026.azurecr.io using the service principal Application ID as the username and the client secret as the password.
- 3Run docker build -t myapp:v1 . on the local runner to create the container image.
- 4Run docker tag myapp:v1 acr2026.azurecr.io/myapp:v1 to prepare the image for the registry.
- 5Run docker push acr2026.azurecr.io/myapp:v1 to upload the image to the registry.
Cevap
The correct sequence of steps requires you to first assign the AcrPush role to the service principal. Next, log in to the registry using the docker login command with the service principal credentials and the registry's login server name (acr2026.azurecr.io). After authenticating, build the image locally with the docker build command, tag the image with the registry's namespace using the docker tag command, and finally push the tagged image to the registry with the docker push command.
To push an image to Azure Container Registry using a service principal, you must first authorize the principal with the AcrPush role. Next, authenticate Docker using the service principal's application ID and client secret against the registry login server. Then, build the image locally, tag it with the target registry's login server namespace, and finally push it.
Adım Adım Çözüm
Anahtar Kavram
Building and pushing container images to Azure Container Registry using service principal authentication and Docker CLI.