45

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.

Janusz Nowak
  • 2,595
  • 1
  • 17
  • 36
donquijote
  • 1,642
  • 5
  • 19
  • 41

4 Answers4

80

(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

Kashyap
  • 15,354
  • 13
  • 64
  • 103
Manohar Reddy Poreddy
  • 25,399
  • 9
  • 157
  • 140
  • 1
    Add "functionTimeout": "00:10:00" to your host.json file – Don Cheadle Apr 15 '19 at 14:40
  • 1
    is there a maximum timeout for an azure function hosted on a web app server? – MIKE May 07 '19 at 21:39
  • @MIKE I lost context of this, see https://github.com/Azure/azure-functions-host/issues/18 and https://github.com/Azure/Azure-Functions/issues/131 , it may help – Manohar Reddy Poreddy May 08 '19 at 11:09
  • 1
    @ManoharReddyPoreddyCan we capture the timeout exception? – Ravi Khambhati Mar 27 '20 at 22:31
  • @RaviKhambhati i lost context of this issue as its been 3 years, check if these 2 links are relevant for your case - https://stackoverflow.com/a/48386699/984471 , https://learn.microsoft.com/bs-latn-ba/azure/azure-functions/durable/durable-functions-error-handling?tabs=csharp#function-timeouts – Manohar Reddy Poreddy Mar 28 '20 at 02:33
  • is that for a single function to execute timeout or general for all functions like going idle timeout? – Emil Jan 31 '21 at 17:57
12

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

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90
4

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.*'
}
Gill-Bates
  • 559
  • 8
  • 22
0

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.

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197