通过 Azure Devops 将 docker 图像部署到 Linux 上的 Web 应用程序失败

Deploying docker image to web app on Linux via Azure Devops fails

我正在尝试通过 Azure Devops 中的发布管道将我的 docker 映像部署到 web app for containers (Linux)。我正在使用任务 Azure Web App for Containers 来完成此任务。

构建映像并将其推送到我在 Azure 中的私有容器注册表工作正常。 但是当我尝试部署我新建和推送的映像时,我收到 身份验证错误 .

Azure Devops 报告部署正常,但是当我在 Azure 的 container settings 选项卡中查看 docker 日志时,我看到身份验证错误。 如果我尝试直接在 container settings 中部署我的图像,它会按预期工作。

以前,我的服务连接到我的 Azure 订阅,我还为我的 Azure 容器注册表添加了一个单独的服务连接。 我没有使用 docker compose,我尝试部署一个 image/container.

Azure Devops 日志:

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

Docker 登录 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)

有人遇到过同样的问题吗? 即使我在 Azure Devops 中添加了服务连接,我是否明确需要向注册表提供凭据?

作为最后的手段,我通过删除我与 Azure Devops 中订阅的服务连接并将其添加回来,让它神奇地工作。 (无需为您的 Azure 容器注册表建立单独的服务连接)

非常沮丧!