如何停止当前在Azure Pipelines上运行WebJobs?

问题描述 投票:0回答:1

我正在尝试部署WebJobs的新版本。我有webjobs.yml个文件,例如;

pool:
  vmImage: 'ubuntu-latest'

[如果我尝试像下面那样停止,则收到错误;

- task: InvokeRESTAPI@1
  inputs:
    connectionType: 'connectedServiceNameARM'
    azureServiceConnection: '$(apiName)'
    method: 'DELETE'
    urlSuffix: 'https://$(apiName).scm.azurewebsites.net/api/triggeredwebjobs/$(apiName)-webjobs'
    waitForCompletion: 'true'

WebJobs-API documentation

Step references task InvokeRESTAPI at version 1.152.1 which is not valid for the given job target

并且如果我使用pool: server,按照建议,我将无法执行其他任务。

我也尝试使用STOP / START,如下所示。它会停止AppService,但不会停止WebJobs。

- task: AzureAppServiceManage@0
  inputs:
    azureSubscription: '$(apiName)'
    Action: 'Stop Azure App Service'
    WebAppName: '$(apiName)'    

并且我最终从Azure收到错误:

The process cannot access the file XYZ because it is being used by another process.

所以,我如何从Azure Pipelines停止当前运行WebJobs并部署新版本?

azure azure-devops azure-pipelines azure-webjobs
1个回答
0
投票

您正在使用Linux代理,首先要注意的是:Linux上的App Service尚不支持WebJobs。这在此document中声明。

这里还有另外两个解决方案,您可以参考:

首先是您可以在临时插槽上设置此粘性应用程序设置:

  • WEBJOBS_STOPPED:1

将此设置设置为1以禁用运行任何作业(也将停止所有当前运行的作业)来源:Kudu Wikicase

第二是可以使用Invoke-AzureRMResourceAction命令。将Azure PowerShell任务添加到定义中。来源:case1 case2

Invoke-AzureRmResourceAction -ResourceGroupName XXX -ResourceType Microsoft.Web/sites/ContinuousWebJobs -ResourceName [web app name]/[web job name] -Action [start/stop] -ApiVersion 2015-08-01 -Force
© www.soinside.com 2019 - 2024. All rights reserved.