Reputation: 9485
I have created a simple azure web job, that goes off grabs some data from a website that's passed in, parses it and adds it to a database.
It's just a simple console app (.exe file) that takes in an argument. And it's uploaded to a web app on Azure.
However, I was under the impression that this webjob would just fire up and finish as many times as needed. So if I fired off 3 commands to the webjob one after the other, I would end up with 3 instances of the webjob running concurrently.
But, it doesn't work. I can only have it running once. The other two commands fail. Is it possible to have a single webjob, in a single web app and have it run concurrently while the same webjob processing something different is also running?
Upvotes: 8
Views: 4695
Reputation: 2513
With Azure WebJobs, you can only run one instance of your webjob per host that you have in your App Service Plan.
Is it possible to have a single webjob, in a single web app and have it run concurrently while the same webjob processing something different is also running?
Yes it is, as long as you scale out your ASP to the desired number of hosts (which is equivalent to the desired number of concurrent webjobs)
Ultimately, you should be looking at Azure functions to handle this type of workload. See this feedback request
Upvotes: 0
Reputation: 58908
Per my experience, a triggered WebJob cannot run concurrently.
What I would suggest is that instead of triggering the job manually, make it a continuous WebJob that listens on queue. Then send a queue message containing the parameters for each run you want. Continuous queue listening jobs can run concurrently.
You will need to modify the job slightly. It'll have to run the job host instead of triggering the logic on start, and you have to move your logic to a queue-triggered function.
Upvotes: 2