8

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?

YodasMyDad
  • 9,248
  • 24
  • 76
  • 121

2 Answers2

2

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.

juunas
  • 54,244
  • 13
  • 113
  • 149
  • Thanks for your comment. Do you have any code examples? – YodasMyDad Jun 18 '17 at 07:41
  • 1
    Continuous queue listening jobs can run in batch (ie: be sent multiple requests at once) but I don't think that is the same as "running concurrently" – CtrlDot Jun 18 '17 at 14:38
  • 1
    https://learn.microsoft.com/en-us/azure/app-service-web/websites-dotnet-webjobs-sdk-storage-queues-how-to#a-idconfiga-how-to-set-configuration-options "The maximum number of queue messages that are picked up simultaneously to be executed in parallel (default is 16)." According to the docs storage queue trigger runs max 16 messages in parallel at once per instance. – juunas Jun 18 '17 at 17:15
0

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

CtrlDot
  • 2,463
  • 14
  • 11