0

I wanted to stop web jobs with a certain name that are currently running on all apps in an app plan in Azure. I prefer PowerShell, but Azure PS module is lacking compared to az cli, so I ended up with the following, which feels really clunky:

Get-AzWebApp
|
where ServerFarmId -EQ '$appPlanId'
|
select Name, ResourceGroup
|
% {az webapp webjob continuous list --name $_.Name --resource-group $_.ResourceGroup --query '[].{Id:id}' | ConvertFrom-Json}
|
% {az webapp webjob continuous stop --webjob-name $webjobName --ids "$($_.Id)"}

I'd appreciate advice on better approaches.

Leon V
  • 541
  • 5
  • 12

1 Answers1

0

As I known, you can use two APIs below of WebJobs API for Continuous Jobs to realize your needs in PowerShell.

  1. List all continuous jobs
  2. Stop a continuous job

For how to call these APIs above, you can refer to the Sample of using REST API with PowerShell.

Meanwhile, please see the document Deployment credentials to know how to use the credentials in the REST calling. And you can refer to my answer for a similar SO thread Unable to access admin URL of Azure Functions to know how to get the credential parameters.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • 1
    I've read about doing it via Kudu's API, but calling a REST API directly doesn't sound like a cleaner way to do it - it would involve even more boilerplate code and using PS won't add much value, not to mention additional dealing with authentication. – Leon V Mar 22 '19 at 01:53