Azure Webjob - Webjob running twice at the same time - Windows server - 2 instances running

Pradeep James 1 Reputation point
2021-02-09T10:15:07.513+00:00

We have few Webjob running on Windows server. Autoscale setttings have been set up for this server and 2 instances are running at a time. One of the webjobs run twice during its scheduled time. Other Webjobs only run once at the scheduled time.

Is there something we need to configure, so that the Webjob runs only once per schedule?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,798 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 26,216 Reputation points Microsoft Employee
    2021-02-09T19:41:39.057+00:00

    @Pradeep James , I see you have posted another question on the WebJob (here), just want to confirm if these are related to the same WebApp/WebJob or it’s isolated/I have already responded on your other thread.

    Just to clarify, I believe you’re referring to App Service on Windows and not on-prem servers?
    Kindly review the ‘settings.job’ file and the CRON expression. It is best to deploy the settings.job as part of the WebJob.

    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).

    Just sharing as additionally info:

    1. There are really 2 sites for each Web App: the normal site and the SCM site (which runs Kudu/WebJobs). Each gets a ping, which is why you see two (the ~1 name is the scm site). See this discussion thread.
    2. As mentioned on the other thread, ensure it is deployed in the right directory/ triggered job copy your binaries (multiples) to: d:\home\site\wwwroot\app_data\jobs\triggered{job name}

    Kindly check this document for more details - https://github.com/projectkudu/kudu/wiki/WebJobs#scheduling-a-triggered-webjob

    3.On the App Service, In the left navigation, click on Diagnose and solve problems – Checkout the tile for “Diagnostic Tools” > “Availability and Performance” & "Best Practices". /Review the WebJob details.

    66034-image.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.