Azure DevOps CI 和用于容器的 Web 应用程序
Azure DevOps CI with Web Apps for Containers
我正在努力为 Azure 中的 Web 应用程序设置 CI 进程。我习惯于将构建的代码直接部署到 Azure 中的 Web 应用程序中,但这次决定使用 docker。
在构建管道中,我构建了 docker 图像并将它们推送到 Azure 容器注册表,标记为最新的构建号。在发布管道(具有 DEV、TEST 和 PROD)中,我需要将这些图像部署到每个环境的 Web 应用程序。 Azure 版本中有 2 个相关任务可用:"Azure App Service deploy" 和 "Azure Web App for Containers"。这些都不允许将 Web 应用程序的图像源设置为 Azure Conntainer Registry。相反,他们采用自定义 registry/repository 名称并将 Web 应用程序中的图像源设置为私有注册表,然后需要登录名和密码。我还使用 ARM 模板部署所有 Azure 资源,因此我不喜欢在 2 个资源(注册表和 Web 应用程序)已经集成时配置凭据的想法。理想情况下,我可以将 Web 应用程序设置为使用我在发布中指定的 Azure 容器注册表中的存储库和标记。我什至尝试首先使用特定的存储库和标签手动配置 Web 应用程序,然后尝试更改 Web 应用程序使用的标签(通过我提到的任务)发布,但它没有用。标签保持不变。
我考虑的另一个选择是从一开始就将所有 Web 应用程序配置到特定的和永久的存储库和标签(例如 "dev-latest")(这不太适合 ARM 部署,因为容器需要存在于在可以配置 Web 应用程序之前注册注册表,因此我的基础设施自动化不完整),在 Web 应用程序中启用 "Continuous Deployment",然后在发布中相应地标记最新推送的存储库,以便 Web 应用程序可以获取它们。我找不到向注册表中的现有存储库添加标签的合理方法。
CI 容器化 Web 应用的 Azure 最佳实践是什么?人们实际上如何构建他们的容器,然后将它们部署到每个环境?
只需为 building an image and pushing it to a container registry 设置 CI 管道。
然后您可以同时使用 Azure App Service 部署和 Azure Web App for Containers 任务来处理部署。
Azure WebApp 容器任务类似于其他内置 Azure 任务,需要 Azure 服务连接 作为输入。 Azure 服务连接存储用于从 Azure Pipelines 或 Azure DevOps Server 连接到 Azure 的凭据。
I'm also deploying all Azure resources using ARM templates so I don't like the idea of configuring credentials when the 2 resources (the Registry and the Web App)
您还可以 Deploy Azure Web App for Containers with ARM and Azure DevOps。
How do people actually build their containers and then deploy them to each environment?
请查看以下博客和官方文档,可能会有帮助:
我正在努力为 Azure 中的 Web 应用程序设置 CI 进程。我习惯于将构建的代码直接部署到 Azure 中的 Web 应用程序中,但这次决定使用 docker。
在构建管道中,我构建了 docker 图像并将它们推送到 Azure 容器注册表,标记为最新的构建号。在发布管道(具有 DEV、TEST 和 PROD)中,我需要将这些图像部署到每个环境的 Web 应用程序。 Azure 版本中有 2 个相关任务可用:"Azure App Service deploy" 和 "Azure Web App for Containers"。这些都不允许将 Web 应用程序的图像源设置为 Azure Conntainer Registry。相反,他们采用自定义 registry/repository 名称并将 Web 应用程序中的图像源设置为私有注册表,然后需要登录名和密码。我还使用 ARM 模板部署所有 Azure 资源,因此我不喜欢在 2 个资源(注册表和 Web 应用程序)已经集成时配置凭据的想法。理想情况下,我可以将 Web 应用程序设置为使用我在发布中指定的 Azure 容器注册表中的存储库和标记。我什至尝试首先使用特定的存储库和标签手动配置 Web 应用程序,然后尝试更改 Web 应用程序使用的标签(通过我提到的任务)发布,但它没有用。标签保持不变。
我考虑的另一个选择是从一开始就将所有 Web 应用程序配置到特定的和永久的存储库和标签(例如 "dev-latest")(这不太适合 ARM 部署,因为容器需要存在于在可以配置 Web 应用程序之前注册注册表,因此我的基础设施自动化不完整),在 Web 应用程序中启用 "Continuous Deployment",然后在发布中相应地标记最新推送的存储库,以便 Web 应用程序可以获取它们。我找不到向注册表中的现有存储库添加标签的合理方法。
CI 容器化 Web 应用的 Azure 最佳实践是什么?人们实际上如何构建他们的容器,然后将它们部署到每个环境?
只需为 building an image and pushing it to a container registry 设置 CI 管道。
然后您可以同时使用 Azure App Service 部署和 Azure Web App for Containers 任务来处理部署。
Azure WebApp 容器任务类似于其他内置 Azure 任务,需要 Azure 服务连接 作为输入。 Azure 服务连接存储用于从 Azure Pipelines 或 Azure DevOps Server 连接到 Azure 的凭据。
I'm also deploying all Azure resources using ARM templates so I don't like the idea of configuring credentials when the 2 resources (the Registry and the Web App)
您还可以 Deploy Azure Web App for Containers with ARM and Azure DevOps。
How do people actually build their containers and then deploy them to each environment?
请查看以下博客和官方文档,可能会有帮助: