I did follow the guidelines mentioned in https://docs.microsoft.com/da-dk/azure/azure-functions/functions-host-json#functiontimeout to increase the default timeout of function app host on app service plan from 30 mins to 2h by updating the host file with "functionTimeout": "02:00:00"
On checking function app's event viewer logs, I could see timeout limit is still 30m. Adding the error message for reference,
<EventData>
<Data>Application: w3wp.exe
CoreCLR Version: 4.6.27317.7
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.Azure.WebJobs.Host.FunctionTimeoutException: Timeout value of 00:30:00 was exceeded by function: CreateRequestApplicationPostProcessor
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryHandleTimeoutAsync(Task invokeTask, CancellationToken shutdownToken, Boolean throwOnTimeout, CancellationToken timeoutToken, TimeSpan timeoutInterval, IFunctionInstance instance, Action onTimeout) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 631
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker, ParameterHelper parameterHelper, CancellationTokenSource timeoutTokenSource, CancellationTokenSource functionCancellationTokenSource, Boolean throwOnTimeout, TimeSpan timerInterval, IFunctionInstance instance) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 547
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance, ParameterHelper parameterHelper, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 503
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstance instance, ParameterHelper parameterHelper, IFunctionOutputDefinition outputDefinition, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 439
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstance instance, FunctionStartedMessage message, FunctionInstanceLogEntry instanceLogEntry, ParameterHelper parameterHelper, ILogger logger, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 249
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstance instance, FunctionStartedMessage message, FunctionInstanceLogEntry instanceLogEntry, ParameterHelper parameterHelper, ILogger logger, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 293
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 89
at Microsoft.Azure.WebJobs.Host.Timers.WebJobsExceptionHandler.<>c__DisplayClass3_0.<OnUnhandledExceptionAsync>b__0() in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Timers\WebJobsExceptionHandler.cs:line 54
at System.Threading.Thread.ThreadMain_ThreadStart()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
</Data>
</EventData>
</Event>
Appreciate your help in overriding a custom timeout value.
In a recent update, the Azure Functions team at Microsoft has added a configuration option that enables an Azure Functions App to have the timeout increased. To implement this, the functionTimeout property within the host. json file for an Azure Function App can be set to a timespan duration of 10 minutes.
You can execute Azure Functions in either a Consumption or an App Service plan. With the Consumption plan, you do not have to worry about the dimension of your infrastructure, scaling, or pay when not utilizing any resources.
How Long Can Azure Functions Run? For any Azure Functions, a single Function execution has a maximum of 5 minutes by default to execute. If the Function is running longer than the maximum timeout, then the Azure Functions runtime can end the process at any point after the maximum timeout has been reached.
In the Azure portal, search for and select App services and select the app that you want to move. From the left menu, select Change App Service plan. In the App Service plan dropdown, select an existing plan to move the app to.
If you run on an App Service plan, you should enable the Always on setting so that your function app runs correctly.
Even with Always On enabled, the execution timeout for individual functions is controlled by the functionTimeout
setting in the host.json project file.
For more details you could refer to this article.
you can always use the attribute [Timeout("1:00:00")] on function level to override the default timeout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With