1
votes

I have a service that runs as an Azure Webjobs and scales out as needed, it's a long running process that can take a few hours for each message on the Queue. It works fine the only issue is that it relies on a third party for a rest endpoint that due to various issues can be unavailable.

My code catches this error and I need it to wait for 10-15seconds before it tries again, and I used

Thread.Sleep(10000);

This works locally but when in Azure as a webjob it seems to Pause all instances of the webjob not just the one that is needing to wait.

Any ideas as to why? each instance is on a difference thread I believe but I am relatively new to WebJobs so can't be 100% sure so some guidance on that would be good as well.

1
Did you try to use async/await method ?Thomas

1 Answers

0
votes

When you scale out the App Service Plan, All instances of the WebJob run independently. If they all sleep at the same time, it could be that the rest endpoint is generally unavailable during that time, leading all of them to sleep.