我在 VSTS 中找到了一个插件 azure app service webjob start 但我无法启动/停止 webjob。请帮助我。在 VSTS 中运行任务时出现以下错误。
错误:
2017-09-25T12:26:37.3203696Z Preparing task execution handler.
2017-09-25T12:26:43.2660796Z Executing the powershell script:
d:\a\_tasks\Start_cbebb02b-11c6-4e24-b5a8-0b51366d51b7\0.2.5\Start.ps1
2017-09-25T12:26:43.6830868Z ##
[error]System.Management.Automation.ParentContainsErrorRecordException: At
D:\a\_tasks\Start_cbebb02b-11c6-4e24-b5a8-0b51366d51b7\0.2.5\Start.ps1:13
char:16
2017-09-25T12:26:43.6830868Z + $WebAppName
2017-09-25T12:26:43.6830868Z + ~
2017-09-25T12:26:43.6830868Z Missing ')' in function parameter list.
2017-09-25T12:26:43.6830868Z
2017-09-25T12:26:43.6830868Z At D:\a\_tasks\Start_cbebb02b-11c6-4e24-b5a8-
0b51366d51b7\0.2.5\Start.ps1:17 char:1
2017-09-25T12:26:43.6830868Z + )
2017-09-25T12:26:43.6830868Z + ~
2017-09-25T12:26:43.6830868Z Unexpected token ')' in expression or
statement.
最佳答案
使用 Invoke-AzureRMResourceAction
命令:
代码:
触发的网络作业:
Invoke-AzureRmResourceAction -ResourceGroupName XXX -ResourceType Microsoft.Web/sites/TriggeredWebJobs -ResourceName [web app name]/[web job name] -Action run -ApiVersion 2015-08-01 -force
连续网络作业:
Invoke-AzureRmResourceAction -ResourceGroupName XXX -ResourceType Microsoft.Web/sites/ContinuousWebJobs -ResourceName [web app name]/[web job name] -Action [start/stop] -ApiVersion 2015-08-01 -Force
具有多个 webjobs 的简单示例脚本:
param(
[object[]]$webjobs,
[string]$website,
[string]$rg
)
foreach($wj in $webjobs){
if($wj.typeName -eq "continuous")
{
Invoke-AzureRmResourceAction -ResourceGroupName $rg -ResourceType Microsoft.Web/sites/ContinuousWebJobs -ResourceName "$website/$($wj.name)" -Action start -ApiVersion 2015-08-01 -Force
}
else{
Invoke-AzureRmResourceAction -ResourceGroupName $rg -ResourceType Microsoft.Web/sites/TriggeredWebJobs -ResourceName "$website/$($wj.name)" -Action run -ApiVersion 2015-08-01 -force
}
}
指定参数:
-webjobs @(@{"name"="webjob1";"typeName"='continuous'},@{"name"="webjob2";"typeName"='continuous'},@{"name"="webjob3";"typeName"='triggered '}) -website XX -rg XX
关于azure - 任何人都可以帮助我如何通过 vsts 停止和启动 azure webjobs 吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46405285/