Search code examples
pythonazureazure-webjobsazure-webjobs-triggered

Multiple Azure Webjobs


I have this Azure App where I am hosting a Webjob.

Whenever I start the app, it runs fine with just 1 Webjob and everything works fine. But as time goes by, out of nowhere, there appears another webjob which is the exact copy of the required webjob.

So the problem is that another webjob (unwanted) is spawned when this functionality is not coded in.

Please see Pic 1 (Required/ As is on Start):

Please see Pic 1 (Required/ As is on Start)

Please see Pic 2 (Unwanted/ Happens After some time):

Please see Pic 2 (Unwanted/ Happens After some time)

This is a triggered webjob with a cron schedule of * * * * * *.


Solution

  • So the problem is that another webjob (unwanted) is spawned when this functionality is not coded in.

    I assume that your situation is resulted from the period of execution time. Please check below statement in the doc:

    In Azure environment, the scheduled webjob will only run on one instance (or worker). This is achieved by using file lock mechanism while the webjob is running. If the webjob happens to run for a very short time, there could be a race condition (such as clock sku) to cause another instance to later start up on the same schedule (since it detects no lock). The workaround is to make sure the webjob run for a certain period of time (say at least 5 seconds assuming schedule interval is greater).

    Also, there is a similar case for your reference: Does Azure start up another instance of a scheduled web job if it is already running?