Azure Functions: Extend Execution Timeout Past 5 Minutes 1Azure Functions is the Serverless compute option within the Microsoft Azure platform. One of the biggest benefits of Azure Functions, and Serverless compute, is that you only pay when your code is actually executing. However, there has been a limitation of Azure Functions in the duration of how long a Function of code can run. This execution time was limited by a hard limit originally set to 5 minutes. For background processes that can be very limiting under certain circumstances. Thankfully, there has recently been an update to Azure Functions that allows you to configure your Azure Functions “maximum execution timeout” to be a little higher!

It’s important to note that the recommended approach to using Azure Functions and Serverless compute is to use architectural patterns like Function Chaining, among others. Function Chaining is a method of breaking up a long running task into multiple shorter running tasks and then linking them together so that each one call the next in the workflow once it completes. This essentially can free you up from the limited time constraints imposed by the Azure Functions Runtime that limits the maximum amount of time a Function can execute before it would be automatically killed off.

Azure Functions: Extend Execution Timeout Past 5 Minutes 2

The original, default timeout for an Azure Function was 5 minutes. This meant that if the Azure Function was running for an elapsed time period of 5 minutes, then the Azure Functions Runtime could end the process at any point after that. Now, it’s not guaranteed that it will end the process and kill the Function being executed, but it’s possible. It’s also not guaranteed that if the Functions takes 1 second longer than 5 minutes that it’ll be allowed to finish execution. Overall, this is a big limitation over the alternative of using Azure Web Jobs which do not have any execution runtime timeout limitation.

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.

// Set functionTimeout to 10 minutes
"functionTimeout": "00:10:00"

// Set functionTimeout to 5 minutes
"functionTimeout": "00:05:00"

The “functionTimeout” in the “host.json” file can be configured to timespans ranging from a minimum of 1 second (00:00:01), up to a maximum of 10 minutes (00:10:00). Remember, the default without overriding the setting will be 5 minutes (00:05:00).

The “host.json” file is a global configuration file for an Azure Functions App. This means that the configuration settings within this file will be applied to all functions hosted within that Azure Functions App. Being a global configuration file for the Function App, it doesn’t reside in the files for a particular Azure Function. Instead, the “host.json” file resides within the main “wwwroot” folder / directory for the Function App as it’s hosted within Azure App Service Plan.

To access and edit the “host.json” file, the simplest approach is to open the App Service Editor (an online IDE of sorts) for the App Service that’s hosting the Azure Functions App. To access the App Service Editor for an Azure Function App, you can follow the below steps to edit the “host.json” configuration file:

  1. Open the Azure Function App blade within the Azure Portal, and click on the Platform features tab at the top of the blade.
    Azure Functions: Extend Execution Timeout Past 5 Minutes 3
  2. On the Platform features tab of the Azure Function App blade, location the Development Tools section of links, and click on App Service Editor.
    Azure Functions: Extend Execution Timeout Past 5 Minutes 4
  3. The App Service Editor will open in a new browser tab.
  4. Locate the host.json file underneath the WWWROOT folder / directory within the App. By default this file will be empty. You can then add the functionTimeout property and set it to your desired timeout threshold, such as 10 minutes (00:10:00).
    Azure Functions: Extend Execution Timeout Past 5 Minutes 5

It’s important to know that the App Service Editor will auto-save ALL changes. This means that you want to be especially careful if you use the App Service Editor in a Production environment. Any typos, or messed up configurations could have adverse affects on the App and potentially cause downtime. Please, use the App Service Editor at your own risk for this reason. In a Dev or Test environment, then you’ll likely be fine as you can always just go back and fix any mistakes easily.

Other options to edit the “host.json” file for an Azure Function App are to use FTP or other deployment tools supported by Azure Functions for managing the deployment process.

Subscribe to Build5Nines Weekly

Subscribe to the Build5Nines Weekly newsletter to receive similar updates about Microsoft Azure, Cloud, and Enterprise news!

We respect your privacy and take protecting it seriously. We do not sell our email list, and you can unsubscribe at any time.

Microsoft MVP

Chris is a Microsoft MVP and has nearly 20 years of experience designing and building Cloud & Enterprise systems. He is also a Microsoft Certified Azure Solutions Architect and developer, a Microsoft Certified Trainer (MCT), and Cloud Advocate. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.

Pin It on Pinterest