1

We are looking to use slots in our Web App, and want to do a slot swap. We have jobs that run on schedule. When we swap the slot, we need to have the job run on the correct schedule for that environment/

What is the recommended way to update the schedule? The preferred approach is to use PowerShell.

Doug Finke
  • 6,675
  • 1
  • 31
  • 47

1 Answers1

1

As David Ebbo commented that you could leverage the Kudu WebJobs API about Set the schedule for a triggered job as follows:

PUT /api/triggeredwebjobs/{job name}/settings

Body {"schedule": "0 */2 * * * *"}

What is the recommended way to update the schedule? The preferred approach is to use PowerShell.

You could leverage the following command:

$username = "<username>"
$password = "<password>"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$contentType='application/json'
$data= @{
   schedule='*/30 * * * * *'
}
$body = $data | ConvertTo-JSON

$apiUrl = "https://<your-appname>.scm.azurewebsites.net/api/triggeredwebjobs/<job-name>/settings"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method Put -Body $body -ContentType $contentType 

Moreover, you could refer to this similar issue.

Bruce Chen
  • 18,207
  • 2
  • 21
  • 35