I am running the below script to validate my Webjobs whether they properly stopped or not after running my Webjobs stop and start scripts though PowerShell task in VSTS.But the below script is sometimes working properly and some times not properly.Because even after stopping my Webjobs,the validation script is saying the webjobs are not stopped.I am not sure why the script is throwing the error.I have double checked with the azure portal Whether the jobs are really stopped/started But in azure ,webjobs are stopped and started successfully but my validation script is throwing the error.Please help me on this.
Validation Script:
$ResourceGroupName="XXX"
$AppService="XXXX"
$Apiversion="2016-08-01"
$errorsJobs=New-Object System.Collections.ArrayList
$continuejobs=Get-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceName $AppService -ResourceType Microsoft.web/sites/ContinuousWebJobs -ApiVersion $Apiversion
foreach($webJob in $continuejobs){
Write-Host $webJob
$status=$webJob.Properties.status
if($status -ne "Running"){
$errorsJobs.Add($webJob.Properties.name)
}}
if($errorsJobs.Count -gt 0){
$result=$errorsJobs -join ";"
Write-Error $result
}
来源:https://stackoverflow.com/questions/47694580/failing-with-the-webjobs-validation-script