0

We are using Azure functions with consumption plan. It is queue triggered and we process customer workflows in the function code. Recently, we saw that function processing got shut down as one execution exceeded 10 minutes processing time limit.

We have now added code to check for time elapsed at various places and exit if we are approaching the limit. However, there can be some corner cases where time limit is reached.

What is the recommended pattern here to ensure that function worker process exits (forced exit if needed) within the time limit. We cannot afford to reach this state:

Timeout value of 00:10:00 was exceeded by function: XXXXXXXX
A function timeout has occurred. Host is shutting down.
Stopping JobHost
Stopping the listener

Or is there a configuration that will kill the individual process instead of job host itself?

Prakash
  • 109
  • 4

1 Answers1

0

is there a configuration that will kill the individual process instead of job host itself?

You can use FunctionTimeout property in host.json file. Set time out x:xx if any process riches to this time its automatically killed.

Azure Function :-

[FunctionName("Function1")]
        public void Run([TimerTrigger("*/5 * * * * *")]TimerInfo myTimer, ILogger log)
        {
            for(int i = 0; i < 10; i++)
            {
                log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
                Thread.Sleep(60000);
                log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
            }
            
        }

Configuration Setting:-

{
  "version": "...",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "..."
      }
    }
  },
  "functionTimeout": "00:04:00"
}

Output :- enter image description here

Mohit Ganorkar
  • 1,917
  • 2
  • 6
  • 11
  • Thanks Mohit. As you can see in my logs, host and listener shut down. What I want is that just that individual process should stop and not the host and listener. – Prakash Jul 12 '22 at 17:36