2

I have to run a stored procedure from azure webjob in continous mode. I have written the code in c# and deployed the same in my development environment.

After monitoring for 3 or 4 days i found, the webjobs aborts if stored procedure runs for long time. My procedure takes approx 50 seconds to return output. While the job aborts by then.

It works fine if stores procedure returns data quickly. Where as if data is more and procedure takes time , i get aborted. But in my case i am looking to keep the job tunning till procedure returns data.

I am not able to figure it out.

I have tried below options

  1. Turning always on ON
  2. stopping_wait_time : 300

Is there any suggestion.?

1 Answers1

0

You can use below code to set the timeout period to solve your problem. For more details, you can see this post about asynchronously wait for Task to complete with timeout. You also can choose other code to implement.

int timeout = 1000;
var task = SomeOperationAsync();
if (await Task.WhenAny(task, Task.Delay(timeout)) == task) {
    // task completed within timeout
} else { 
    // timeout logic
}

Due to your azure webjob in continous mode, you can't use WEBJOBS_IDLE_TIMEOUT setting. But your webjobs will always on, you also can set WEBJOBS_RESTART_TIME to re-launch.

enter image description here

Jason
  • 9,555
  • 1
  • 8
  • 18