Reputation: 536
I've a web job that grab a file from internet and process it. I have tied it s to a scheduler that run everyday at the mid-night.
Sometimes the grab file process fails and throws an exception which crashes the web jobs and stops till the scheduler kicks again next day.
To stop the app from crashing, one option I have is to wrap it with a try-catch block and handle the error. But I want to be able to re-run the web jobs after it fails.
Is there a way for me to tell the azure scheduler to re-run the task for N number of times after it fails?
For example, I want the web jobs to be re-run after 5 minutes of fail for at-most 5 times. I don't want to wait for the scheduler to kick in next day.
Upvotes: 3
Views: 1348
Reputation: 15627
Is there a way for me to tell the azure scheduler to re-run the task for N number of times after it fails?
Azure Scheduler does not provide a way to verify if the "remote" execution succeeded or not, but you can use a "Storage Queue" Action Type to put a message into a specified queue and achieve the same behavior in the web job itself. The Azure Web Jobs SDK will process the incoming message and retry up to 5 times if an exception is thrown, also the queue processor is extensible (since 1.1), so you can easily implement an exponential retry policy or whatever policy you need (by extending QueueProcessor and QueueProcessorFactory classes).
Steps:
[QueueTrigger("myqueue")]
), and configure it as "Continuous Running" (in the VS project and the azure Web App).note: this option requires Standard Tier in your Web App (due "Continuous Running")
Upvotes: 4