7
votes

I am trying to deploy my docker image to a web app for containers (Linux) via the release pipeline in Azure Devops. I am using the task Azure Web App for Containers to accomplish this.

Building and pushing the image to my private container registry in Azure works fine. But when I'm trying to deploy my newly built and pushed image, I get an authentication error.

Azure Devops reports the deployment went fine but when I am looking in the docker logs in the tab container settings in Azure I see an authentication error. If I try to deploy my image directly in the container settings it works as expected.

Previously I have my service connection to my Azure subscription and I also added a separate service connection for my Azure Container Registry. I am not using docker compose and I try to deploy a single image/container.

Azure Devops logs:

2019-08-12T13:48:47.3512681Z ##[section]Starting: Azure Web App on Container Deploy: my-service
2019-08-12T13:48:47.3676562Z ==============================================================================
2019-08-12T13:48:47.3676709Z Task         : Azure Web App for Containers
2019-08-12T13:48:47.3676775Z Description  : Deploy containers to Azure App Service
2019-08-12T13:48:47.3676828Z Version      : 1.0.22
2019-08-12T13:48:47.3676870Z Author       : Microsoft Corporation
2019-08-12T13:48:47.3676932Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-containers
2019-08-12T13:48:47.3677003Z ==============================================================================
2019-08-12T13:48:47.6472308Z Got service connection details for Azure App Service:'my-service'
2019-08-12T13:48:48.7565776Z Single-container Deployment to the webapp 'my-service' as only the image detail was sepcified.
2019-08-12T13:48:49.2180101Z Updating App Service Configuration settings. Data: {"appCommandLine":null,"linuxFxVersion":"DOCKER|my-registry.azurecr.io/my-repository:latest"}
2019-08-12T13:48:51.1744261Z Updated App Service Configuration settings.
2019-08-12T13:48:51.1752210Z Restarting App Service: my-service
2019-08-12T13:48:51.6881923Z App Service 'my-service' restarted successfully.
2019-08-12T13:48:54.9987139Z Successfully updated deployment History at https://my-service.scm.azurewebsites.net/api/deployments/12431565617733135
2019-08-12T13:48:55.5252693Z App Service Application URL: https://my-service.azurewebsites.net
2019-08-12T13:48:55.5391444Z ##[section]Finishing: Azure Web App on Container Deploy: my-service

enter image description here

Docker logs in Azure:

2019-08-12 07:54:11.184 INFO  - Pulling image: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:11.424 ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for my-registry.azurecr.io/my-service:20190812.8 not found: manifest unknown: manifest unknown"}

2019-08-12 07:54:11.425 ERROR - Pulling docker image my-registry.azurecr.io/my-service:20190812.8 failed:
2019-08-12 07:54:11.426 INFO  - Pulling image from Docker hub: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:11.461 ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://my-registry.azurecr.io/v2/my-service:/manifests/20190812.8: unauthorized: authentication required"}

2019-08-12 07:54:11.463 ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2019-08-12 07:54:13.482 INFO  - Pulling image: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:13.588 ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for my-registry.azurecr.io/my-service:20190812.8 not found: manifest unknown: manifest unknown"}

2019-08-12 07:54:13.593 ERROR - Pulling docker image my-registry.azurecr.io/my-service:20190812.8 failed:
2019-08-12 07:54:13.593 INFO  - Pulling image from Docker hub: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:13.628 ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://my-registry.azurecr.io/v2/my-service:/manifests/20190812.8: unauthorized: authentication required"}

2019-08-12 07:54:13.629 ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2019-08-12 07:54:17.116 INFO  - Pulling image: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:17.244 ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for my-registry.azurecr.io/my-service:20190812.8 not found: manifest unknown: manifest unknown"}

2019-08-12 07:54:17.245 ERROR - Pulling docker image my-registry.azurecr.io/my-service:20190812.8 failed:
2019-08-12 07:54:17.246 INFO  - Pulling image from Docker hub: my-registry.azurecr.io/my-service:20190812.8
2019-08-12 07:54:17.281 ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://my-registry.azurecr.io/v2/my-service:/manifests/20190812.8: unauthorized: authentication required"}

2019-08-12 07:54:17.283 ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)

Anyone experienced the same problem? Do I explicit need to provide the credentials to the registry even though I added a service connection in Azure Devops?

1
Do I need to setup a Service Principal for this to work?Hypnobrew

1 Answers

2
votes

As a last resort I got it to magically work by removing my service connection to the subscription in Azure Devops and added it back. (No need to have a separate service connection for your Azure Container Registry)

Highly frustrating!