简体   繁体   English

如何从 azure 发布管道查询当前部署到应用程序服务的 docker 图像?

[英]How can I query which docker image is currently deployed to an app service from an azure release pipeline?

I have an Azure release pipeline that uses an Azure Web App for Containers task to deploy a docker image on an Azure App Service.我有一个 Azure 发布管道,它使用Azure Web App for Containers任务在 Azure App Service 上部署 docker 图像。

The image is specified in the form of some_image:$(Build.BuildId) .图像以some_image:$(Build.BuildId)的形式指定。 The pipeline works as intended and successfully updates the App Service with the latest built of the image.管道按预期工作,并使用最新构建的映像成功更新应用服务。

I want from an other release pipeline to execute a docker run command using that image.我想从其他发布管道使用该图像执行docker run命令。 I've noticed that version 1 of the Docker task allows me to execute such a docker run command on a docker image (no idea why run is missing from version 2), but how can I specify the docker image?我注意到Docker任务的版本 1 允许我在 docker 图像上执行这样的docker run命令(不知道为什么版本 2 中缺少运行),但我如何指定 docker 图像? How can I get which image is the currently deployed on that App Service?如何获取当前部署在该应用服务上的图像?

You can either use PowerShell or Shell script in the YAML pipeline .您可以在YAML 管道中使用 PowerShell 或 Shell 脚本。 Since you already know the container registry and the image name, just use the below command to get the latest version由于您已经知道容器注册表和镜像名称,因此只需使用以下命令获取最新版本

az acr repository show-tags -n MyRegistry --repository MyRepository --top 1 --orderby time_desc --detail

https://docs.microsoft.com/en-us/cli/azure/acr/repository?view=azure-cli-latest#az_acr_repository_show_tags https://docs.microsoft.com/en-us/cli/azure/acr/repository?view=azure-cli-latest#az_acr_repository_show_tags

Might be too late now, but what you want to do is to get the value of LinuxFXVersion (if you're running docker on Linux) property from Azure Resource Explorer.现在可能为时已晚,但您要做的是从 Azure Resource Explorer 获取 LinuxFXVersion(如果您在 Linux 上运行 docker)属性的值。

Using a combination of Azure PowerShell and CLI, you can have these commands to retrieve the current image running on your web app:结合使用 Azure PowerShell 和 CLI,您可以使用这些命令来检索在 web 应用程序上运行的当前图像:

 $webAppProperties = (az webapp config show --subscription "<subscription-id>" --resource-group "<resource-group-name>" -n "<webapp-name>") | ConvertFrom-Json
 $webAppProperties.linuxFXVersion

Assuming you have the right permissions to your subscription from Azure Pipelines, you should be able to use this information for the next steps.假设您拥有从 Azure Pipelines 订阅的正确权限,您应该能够在后续步骤中使用此信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 等待新部署的应用服务在 Azure Devops 发布管道中重新启动 - Waiting for a freshly deployed app service to be restarted in Azure Devops Release pipeline 如何从位于不同订阅中的 ACR 将映像部署到 Azure 应用服务? - How can I deploy image to Azure App Service from an ACR which is located in different subscription? dockerize create-react-app如何在docker环境下访问azure发布管道变量 - How dockerize create-react-app can access to azure release pipeline variables in docker environment 作为 Azure DevOps 发布管道的一部分,从应用服务中删除文件 - Delete files from app service as part of Azure DevOps release pipeline 如何使用特权选项在 Azure 应用服务中运行 docker 映像? - How can I run docker image in Azure app service with privileged option? Azure Ubuntu 中的管道部署到 Azure 中的应用程序服务 Z6FE8B98C363E8D08594681 - Azure Pipeline in Ubuntu deployed to Azure App Service in Debian 如何在 Azure DevOps 发布管道中保存测试结果 - How can I save testing results in Azure DevOps release pipeline Azure 应用服务不断从 docker 集线器拉取 docker 映像 - Azure App service Keeps pulling docker image from docker hub Azure Devops Release Pipeline - 将单个文件部署到Azure App Service - Azure Devops Release Pipeline - Deploy single file to Azure App Service Azure Devops发布管道-未更新Azure App Service文件 - Azure Devops Release Pipeline - Azure App Service files not updated
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM