Reputation: 1822
Is there a way to change the current 5 minutes timeout limit for Azure Functions running under the Consumption plan ?
For some data analytics computations 5 minutes is not enough time.
The alternative of using webjobs doesn't allow parallel execution of the function.
Upvotes: 46
Views: 75392
Reputation: 8955
Although the existing answers explain how one can configure the timeout for Azure Functions, none of them alert to the fact that one of the most popular Azure Function types (Http Triggered Function) timeouts after 230 seconds. Mine was timing out before the mentioned (default) 5 min due to this.
The following screenshot from Microsoft's website answers the question without skipping this very important detail:
Microsoft website - Function app timeout duration
It says: "Regardless of the function app timeout setting, 230 seconds is the maximum amount of time that an HTTP triggered function can take to respond to a request. This is because of the default idle timeout of Azure Load Balancer. For longer processing times, consider using the Durable Functions async pattern or defer the actual work and return an immediate response."
Upvotes: 0
Reputation: 1
You can change the plan to premium but you need to create a new function because you can't change it once it's created already. premium plan has no overall limit.
Here is the official documentation.
Upvotes: 0
Reputation: 18387
Azure Functions can now run up to 10 minutes using the consumption plan: https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#functiontimeout
Upvotes: 12
Reputation: 679
Here the complete host.json
, recarding to the Microsoft Docs:
Don't forget to restart the Function to reload the Configuration!
{
"version":"2.0",
"managedDependency":{
"Enabled":true
},
"extensionBundle":{
"id":"Microsoft.Azure.Functions.ExtensionBundle",
"version":"[2.*, 3.0.0)"
},
"functionTimeout": "00:05:00"
}
Another trick is, only to define the required Az-Modules in requirements.psd1
and not all of them:
Bad:
# This file enables modules to be automatically managed by the Functions service.
# See https://aka.ms/functionsmanageddependency for additional information.
#
@{
# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'.
# To use the Az module in your function app, please uncomment the line below.
'Az' = '6.*'
}
Good:
# This file enables modules to be automatically managed by the Functions service.
# See https://aka.ms/functionsmanageddependency for additional information.
#
@{
# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'.
# To use the Az module in your function app, please uncomment the line below.
# 'Az' = '6.*'
'Az.Accounts' = '2.*'
'Az.Resources' = '4.*'
'Az.Monitor' = '2.*'
}
Upvotes: 4
Reputation: 27495
(Other answer is a bit confusing, so writing instead of editing a lot)
Azure Functions can now run up to 10 minutes using the consumption plan by adding the functionTimeout
setting to your host.json
file:
In a serverless Consumption plan, the valid range is from 1 second to 10 minutes, and the default value is 5 minutes.
In both Premium and Dedicated (App Service) plans, there is no overall limit, and the default value is 30 minutes. A value of -1 indicates unbounded execution, but keeping a fixed upper bound is recommended
Source: https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#functiontimeout
File: host.json
// Value indicating the timeout duration for all functions.
// Set functionTimeout to 10 minutes
{
"functionTimeout": "00:10:00"
}
Source:
https://buildazure.com/2017/08/17/azure-functions-extend-execution-timeout-past-5-minutes/
https://github.com/Azure/azure-webjobs-sdk-script/wiki/host.json
Upvotes: 82