Search code examples
azureazure-devopsazure-web-app-serviceazure-pipelines-release-pipelineazure-container-registry

Azure Release Pipeline fails when try to pull image from ACR


I try to use Azure pipelines for ci and cd.

1- My application image is built and pushed to azure container registry.

2- Release pipeline try to pull image from ACR it gets error. Logs from container settings:

INFO  - Pulling image: registryname/repo:latest
ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://registry-1.docker.io/v2/registryname/repo/manifests/latest: unauthorized: incorrect username or password"}

ERROR - Pulling docker image registryname/repo:latest failed:
INFO  - Pulling image from Docker hub: registryname/repo:latest
ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"pull access denied for registryname/repo, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"}

ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
INFO  - Stopping site appname because it failed during startup.

Ss from configuration: enter image description here

Thanks for your help.


Solution

  • When you use the ACR to store the image and want to deploy the images in it to Azure Web App, you need to set the image name as ACRName.azurecr.io/image:tag, not just the image name and tag. And set the environment variables like:

    DOCKER_REGISTRY_SERVER_USERNAME - The username for the ACR server. DOCKER_REGISTRY_SERVER_URL - The full URL to the ACR server. (For example, https://my-server.azurecr.io.) DOCKER_REGISTRY_SERVER_PASSWORD - The password for the ACR server.

    And the credential should have enough permissions. When all things are OK, the container logs will look like this:

    enter image description here