如何通过Azure Pipelines将多个docker映像部署到Azure App Service

问题描述 投票:0回答:2

我有一个docker compose .yml文件,可用于在Linux Azure App Service上手动安装和运行多个docker映像。我的下一步是通过Azure Pipelines使此过程自动化,我已经成功完成了单个映像的创建。但无法弄清楚如何对同一App Service实例上的多个图像执行此操作。

这是客户端要求,在同一个App Service实例上运行多个图像。如果有更好的方法,我会有一定的灵活性,但是成本是一个因素。

我专门在寻找要添加到我的发布管道中的任务类型,是否有我可以阅读的示例或文档。到目前为止,我还没有找到任何真正符合要求的内容,但是我不是DevOps工程师,所以很可能我只是没有正确地提出问题。

这是我拥有的docker compose yml文件的示例。

version: '3.7'
    services:
      exampleapi:
        image: examplecontainerregistry.azurecr.io/example.api:latest
        container_name: example.api
        volumes:
          - example:/mnt/example
          - common:/mnt/common
      certprojectservice:
        image: examplecontainerregistry.azurecr.io/example.certproject.service:latest
        container_name: example.certproject.service
        volumes:
          - example:/mnt/example
          - common:/mnt/common 
      unityemailservice:
        image: examplecontainerregistry.azurecr.io/example.email.service:latest
        container_name: example.email.service
        volumes:
          - example:/mnt/example
          - common:/mnt/common   
      eventconsumerservice:
        image: examplecontainerregistry.azurecr.io/example.eventconsumers.service:latest
        container_name: example.eventconsumers.service
        volumes:
          - example:/mnt/example
          - common:/mnt/common 
      webhookresponseservice:
        image: examplecontainerregistry.azurecr.io/example.webhookresponse.service:latest
        container_name: example.webhookresponse.service
        volumes:
          - example:/mnt/example
          - common:/mnt/common 
      unitywebhooksservice:
        image: examplecontainerregistry.azurecr.io/example.webhooks.service:latest
        container_name: example.webhooks.service
        volumes:
          - example:/mnt/example
          - common:/mnt/common 
docker-compose azure-web-sites azure-pipelines-release-pipeline docker-container
2个回答
1
投票

不确定我使用的方法是否适合您,但是可以检查一下。

[1)要在一个Azure应用服务实例中运行多个docker映像,首先我需要使我的Azure App服务类型可用于Docker-Compose

enter image description here

注意:由于我的图像存储在ACR中,因此在这里我将此Azure应用程序服务连接到我使用的ACR。

[2)docker-compose.yml上载到该configuration

3)第三步,即非常有意义的步骤是启用Continuous Deployment。此步骤的意义在于,一旦有新图像推送到与当前应用程序服务连接的ACR中。它将自动从ACR获取最新的映像,然后将其部署为配置的docker-compose文件。

启用持续部署后,单击显示URL以获取wehhook URL:

enter image description here

4)转到ACR,然后从左侧面板中选择WebhooksAdd=>输入从AppService复制到webhook URLService URL。保存。

enter image description here


现在,每次将映像的新版本推送到ACR时,Azure App Service都会使用最新映像触发容器的重新部署。而且,我不需要在azure devop中使用部署任务配置管道。


0
投票

因此,对于任何有兴趣的人,我能够解决自己存在的情况的方式是确保在构建管道期间,我将docker compose文件作为管道工件推送。然后,在发布管道中,我能够下载该工件并在Azure CLI任务中使用它。

CLI任务使用了“ az webapp配置容器集”命令。一旦我弄清楚,它就相当简单了,但是更适合目标任务的将是不错的。

Release Pipeline

© www.soinside.com 2019 - 2024. All rights reserved.