Cameron Aavik
Cameron Aavik

Reputation: 812

Azure WebJob not running as per schedule

I have an issue where an Azure WebJob I created (on a Web App) is not running using the cronjob Trigger I specified. I am able to click on the WebJob, then click Run and it does run fine with no errors. A screenshot of the WebJobs in the portal is shown below.

WebJobs List
As you can see, the Trigger is set to run at 9:30 AM every day, but it is never run automatically as per the trigger, only manually using Run. The WebJob itself is set to run a .exe which is contained inside a .zip.

Here are the settings I used when creating the WebJob.
Creating new WebJob

Upvotes: 9

Views: 11461

Answers (5)

Daniël
Daniël

Reputation: 1

I faced the same problem of a webjob that did not run on the scheduled time. In my case the problem was having configuration values WEBJOBS_DISABLE_SCHEDULE=1 and WEBJOBS_STOPPED=1 being present in the App Service configuration.

See https://learn.microsoft.com/en-us/azure/app-service/webjobs-create?tabs=windowscode#manage-webjobs

Upvotes: 0

Devanathan.S
Devanathan.S

Reputation: 1472

Faced the similar issue.With reference to the below link

https://raskarovblog.wordpress.com/2017/03/16/why-is-my-azure-webjob-cron-expression-is-not-working/

Azure team states that Azure WebJob CRON uses NCronTab with six parameters (five and seven parameters are not accepted).

If you look at NCronTab Docs, you will notice that they use 5 parameters. Azure team explains that they also pass “Seconds” parameter which is not used by default by NCronTab.

Cron format below

{second} {minute} {hour} {day} {month} {day of the week}

To run the webjobs every day at 9.30 am will be

{"schedule":"0 30 9 * * *"}

And also check the time scheduled in the azure webjobs and your local time.

Upvotes: 5

Chris
Chris

Reputation: 41

Just putting this here for the googlers.

Remember Azure is running on UTC time so 9:30 in your timezone might be different in Azure time.

I'm PST so if I want to run something at 9:30 I set my CRON expression to 16:30. This becomes a problem with daylight savings time if you need your job to execute at exactly 9:30, you will need to change the CRON expression because UTC does not change with DST.

Upvotes: 0

Pieter Heemeryck
Pieter Heemeryck

Reputation: 683

As mentioned in the comments of David Ebbo's answer, the webjob won't be triggered automatically if your CRON expression is not correct.

In this piece of relevant MS documentation, the following CRON expression is mentioned and does not work:

{
"schedule": "0 */15 * * * *"
}

Instead, use this:

{
"schedule": "0 0/15 * * * *"
}

This way I got my webjob running every 15 minutes.

Upvotes: 2

David Ebbo
David Ebbo

Reputation: 43193

You need to make sure you have Always On enabled in your App, which requires it to run in Basic or higher mode.

See https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/#CreateScheduledCRON for details.

Upvotes: 11

Related Questions