[英]Waiting for a freshly deployed app service to be restarted in Azure Devops Release pipeline
[英]How can I query which docker image is currently deployed to an app service from an azure release pipeline?
我有一个 Azure 发布管道,它使用Azure Web App for Containers
任务在 Azure App Service 上部署 docker 图像。
图像以some_image:$(Build.BuildId)
的形式指定。 管道按预期工作,并使用最新构建的映像成功更新应用服务。
我想从其他发布管道使用该图像执行docker run
命令。 我注意到Docker
任务的版本 1 允许我在 docker 图像上执行这样的docker run
命令(不知道为什么版本 2 中缺少运行),但我如何指定 docker 图像? 如何获取当前部署在该应用服务上的图像?
您可以在YAML 管道中使用 PowerShell 或 Shell 脚本。 由于您已经知道容器注册表和镜像名称,因此只需使用以下命令获取最新版本
az acr repository show-tags -n MyRegistry --repository MyRepository --top 1 --orderby time_desc --detail
现在可能为时已晚,但您要做的是从 Azure Resource Explorer 获取 LinuxFXVersion(如果您在 Linux 上运行 docker)属性的值。
结合使用 Azure PowerShell 和 CLI,您可以使用这些命令来检索在 web 应用程序上运行的当前图像:
$webAppProperties = (az webapp config show --subscription "<subscription-id>" --resource-group "<resource-group-name>" -n "<webapp-name>") | ConvertFrom-Json
$webAppProperties.linuxFXVersion
假设您拥有从 Azure Pipelines 订阅的正确权限,您应该能够在后续步骤中使用此信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.