Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens when a scheduled WebJob runs for a long time

What happens if an Azure WebJob is scheduled to run but the previous running instance hasn't finished yet? Will it run the WebJob again so that two are running at once? Will it not run the WebJob and start the clock over? I haven't been able to find this behavior documented anywhere. I have a job I want to run hourly but it's possible that sometimes it might take longer than an hour to complete, but I never want two of them running at once.

like image 995
BowserKingKoopa Avatar asked Apr 09 '15 15:04

BowserKingKoopa


1 Answers

As i understand it scheduled webjobs is just triggered webjobs that is run using Azure Scheduler, if you open Azure Scheduler in management portal you can see the webjobs and even configure them in more detail. (You can see the log too which would give you the simple answer to your question).

If you like to look at whats going on your scheduled webjob is run as a Triggered webjob by Kudu, if you look in the Kudu source you will see that a lockfile is created when a job is started, and if you try to start another job a ConflictException is thrown if there is already a lock file

The Azure scheduler calls your job using a webhook that catches the ConflictException and gives you the "Error_WebJobAlreadyRunning" warning which will tell you: "Cannot start a new run since job is already running."

like image 77
jakobandersen Avatar answered Oct 19 '22 09:10

jakobandersen