强制停止 Azure 应用服务部署槽交换

问题描述

我们正在使用 Azure DevOps 部署到暂存槽,然后与生产交换。 当交换出现问题时,它将持续尝试近 30 分钟。

因此,我想为交换任务设置一个超时时间,但如果我这样做,它会在 DevOps 中停止该任务并让该过程在 Azure 中进行。

我想要一种通过 CLI、API、PowerShell 或 DevOps 任务强制停止进程的方法

Azure CLI 好像什么都没有 Kudu API 可以删除部署,但不会阻止它们 (https://github.com/projectkudu/kudu/wiki/REST-API#deployment)

我了解到您可以停止进程,但使用 Linux 容器应用服务时,我看不到该选项。 Azure-Web-sites: How to cancel a deployment?

有办法吗?

解决方法

更新

If any errors occur in the target slot (for example,the production slot) after a slot swap,restore the slots to their pre-swap states by swapping the same two slots immediately

enter image description here

所以,我们不需要停止它,只需等待交换操作成功即可。

当您提交交换槽请求时,您将获得 HttpStatus 202 代码。在portal上点击swap按钮,会发现浏览器一直在请求location的url来获取swap状态。

至于什么时候结束,我们可以通过轮询来检查交换操作。

如果swap操作时间过长,建议提出支持工单,让工程师检查原因。

原始

您可以使用 AzureAppServiceManage 任务。

Azure App Service Manage task

使用此任务来启动、停止、重新启动、槽交换、与预览交换、安装站点扩展或启用对 Azure 应用服务的持续监控。

提示

当您使用rest api交换槽时,您可以在响应头中检查location

enter image description here

当您提交交换槽请求时,您将获得 HttpStatus 202 代码。在portal上点击swap按钮,会发现浏览器一直在请求location的url来获取swap状态。