Conflict 409 Error Triggering webjob running on multiple webapp instances

344 views Asked by At

I've hosted a NodeJS webjob on a webapp that has 5 running instances. I'm triggering the webjob using the Kudu API

https://xyz.scm.azurewebsites.net/api/triggeredwebjobs/webjobname/run

The first request is accepted and webjob starts running but any subsequent request is giving error because the job is in running state.

HTTP 409 Cannot start a new run since job is already running.

I expect that I should be able trigger using the REST endpoint 5 times and another instance of webapp hosting the "free" job should pick it up. Is that not possible? Can you only trigger a single webjob despite of number of webapp instances you're running?

Increased scaling of App service plan to 5 instances and tried triggering the 'triggered webjob' with KUDU API Expectations : Should be able to submit 5 requests since the 'free instance' will handle the request Actual : First request is submitted with HTTP 202, any other request fails with 409 until the first webjob finishes running.

1

There are 1 answers

0
Harshitha On

As mentioned in the MSdoc to run a WebJob on multiple instances use Continuous Job.

If your web app runs on multiple instances, a continuous WebJob runs on each instance, listening for triggers and calling functions.

  • We can see the same in the App Service as well, only continuous job has the multiple instance option.

Triggered Job: enter image description here

Continuous Job: Continuous Web Jobs can be scaled to run multiple instances.

enter image description here

Using KUDU API:

enter image description here

Increased scaling of App service plan to 5 instances and tried triggering the 'triggered webjob' with KUDU API Expectations :

As triggered jobs run only in single instance scaling up of the App Service plan does not make any changes.

Also refer the SOThreads 1 and 2 which explains running multiple instances of Web Jobs at once.