2
votes

I have an ASP.NET MVC5 application running as an App Service in Azure and want to schedule a WebJob to execute a console app every hour.

In the console application I have webjob-publish-settings.json file defined as:

{
  "$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
  "webJobName": "EpisodeUpdater",
  "startTime": "2017-05-01T00:00:00-08:00",
  "endTime": "2020-06-01T00:00:00-08:00",
  "jobRecurrenceFrequency": "Hour",
  "interval": 1,
  "runMode": "Scheduled"
}

When I look in the Azure portal the type of WebJob appears to be set as Triggered - the job will run successfully when I start it manually but it doesn't execute every hour.

WebJobs

WebJob properties

Can anyone see why the WebJob isn't scheduled properly?

1
What does your PublishProfile look like? How do you deploy the WebJob? Do you 'just' put it in the Jobs folder, or are you for instance using the WebJobs SDK (recommended!)rickvdbosch

1 Answers

7
votes

In a way there are no Scheduled jobs. A scheduled WebJob is just an On-demand/Triggered WebJob that is triggered by a timer. Now this timer can be Azure Scheduler (which is what VS tooling used to create) or the built-in scheduler in Kudu.

To use the built-in scheduler, you create file called settings.job in the root of the project and have this as the content:

{
    "schedule": "0 0 * * * *"
}

That will run it every hour. It uses CRON expressions, in this case defining it should run always when seconds and minutes are zero. Now this does require Always On to be on in the app.

Documentation: https://docs.microsoft.com/en-gb/azure/app-service/web-sites-create-web-jobs#CreateScheduledCRON