Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure function app timeout for app service plan

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.&lt;&gt;c__DisplayClass3_0.&lt;OnUnhandledExceptionAsync&gt;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.

like image 513
Lakshmana Prabhu Venkatesan Avatar asked Apr 09 '19 06:04

Lakshmana Prabhu Venkatesan


People also ask

How do I increase the timeout on my Azure function app?

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.

Does an Azure function need an App Service plan?

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 function app run?

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.

How do I change the App Service plan for function app?

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.


Video Answer


2 Answers

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.

like image 155
Joey Cai Avatar answered Oct 14 '22 00:10

Joey Cai


you can always use the attribute [Timeout("1:00:00")] on function level to override the default timeout

like image 27
Ayman Chliah Avatar answered Oct 13 '22 23:10

Ayman Chliah