[英]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.