
Azure 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!
Pricing Tier Timeout Differences
The Azure Function Timeout is difference depending on which hosting method / pricing tier is used to host an Azure Function App. While in the Consumption plan, the default timeout is 5 minutes, there is a different default and maximum timeouts for the Premium and Dedicated pricing tiers.
Here are the different timeouts for each of the Azure Functions pricing tiers, along with the default and maximum values that can be set using the functionTimeout
configuration property within the host.json
file:
Pricing Tier | Default Timeout | Minimum | Maximum |
---|---|---|---|
Consumption Plan | 5 min | 1 min | 10 min |
Premium Plan | 30 min | 1 sec | 60 min |
App Service Plan | 30 min | No limit (set using -1 value |
* Regardless of the Function App Timeout configuration, 230 seconds is the maximum amount of time that an HTTP Triggered function can take to respond to a request.
The pricing tier used to host an Azure Function App needs to be factored into the decision on what the individual function execution timeout will be for functions within that app. Also, if it’s known that certain functions will take longer to execute, then the appropriate pricing tier should be chosen for hosting.
In relation to the dedicated App Service Plan function timeout, there is no upper limit on the execution timeout. To enable “unlimited execution time” the functionTimout
configuration can be set to the value of -1
. However, it is strongly recommended to keep a fixed upper bound so the app is prevented from getting into infinite loop scenarios.
functionTimeout
Configuration in host.json
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" } // Set functionTimeout to 60 minutes (1 hour) { "functionTimeout": "01:00:00" } // Set functionTimeout to "No Limit" // Generally not recommended, just in case of infinite loop scenarios { "functionTimeout": "-1" }
The functionTimeout
in the host.json
file can be configured using a timespan string format ranging from a minimum of 1 second (00:00:01
), up to a maximum of 10 minutes (00:10:00
) for Consumption Plan hosting and Unlimited (-1
) for Premium and Dedicated Plans . Remember, the default without overriding the setting will be 5 minutes (00:05:00
) or 30 minutes (00:30:00
) depending on the hosting plan type used.
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 for the Function App as it’s hosted within the internal App Service Plan.
Edit host.json
file within Azure Portal
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. This is something that can be done within the Azure Portal without requiring you to republish the Azure Function source code. However, when doing this, it is not recommended to do in production if you are using a CI/CD pipeline to deploy the code of your solution.
To access the App Service Editor for an Azure Function App, you can follow the below steps to edit the host.json
configuration file:
- Open the Azure Function App within the Azure Portal.
- In the list of options on the left-side, select the App Service Editor option underneath the Development Tools section, then click the Go link to open the App Service Editor.
- The App Service Editor will open in a new browser tab. As you can see, the editor has a similar UI to what you may already be familiar with in Visual Studio Code.
- 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).
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.
Timeout vs Function Chaining
It’s important to note that the recommended approach to using Azure Functions and Serverless compute is to use architectural patterns like Function Chaining using the Durable Functions capabilities of Azure Functions. 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.

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.
There is a simple typo in the first line of the second paragrah. “It’s important to not that” it is ‘note’ and ‘not’. I like this article. Thank you!
Fixed. Thanks!
What are my options in Azure stack if I wan’t to keep a background task running until explicitly interrupted? I am looking for something other than VM. Loved the server-less architecture of function app but not solution I have been look for. Eg. task could be like collecting twitter stream or constantly looking for change in stock prices, etc.
Any help is deeply appreciated.
You could use a Continuously running Web Job.
Continuously running a WebJob would require me to deploy a VM, if I am not wrong. Any other way you could suggest ?
WebJobs are part of App Service PaaS feature, not VMs. But yes there would still be a Managed VM underneath.
You can have a function or webjob on a timerTrigger.
One thing worth mentioning is this timeout only applies when running in an consumption plan. When running in a regular app service plan, no time limit applies and your Functions can run as long as you like. This is covered in the docs https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale
Why not use durable tasks ? Only thing u need to take care of is modularity of your code. And knowledge of Durable Task Framework.
Hi Chris,
Thanks for the info, however I have couple of doubts,
1) Is this configuration needed for app service plan, as I have read in couple of sites that app service plan has indefinite time limit
2) I have written durable function (function chaining), and when the last activity trigger is called and waiting for the response, it timed out even after introducing this configuration. In the background, the called method is being executed. Could you please help what could be the issue here?
Thanks in advance.
1) App Service Plans do not have any timeout limit for Azure Functions running, so this setting is not needed there.
2) The orchestrator function with Durable Functions can have an overall execution time longer than the limit since it delegates tasks out to asynchronously running Functions. If you have loops or other activities within the orchestrator function, then you could hit up against the timeout limit there though. Each of the individual Functions running within the chain will still be limited to the execution timeout limit for each Function; at least if your using Consumption Plan pricing.
hi Chris,
I am using Consumption Plan for Dev environment and Premium Plan for Live using CICD to do deployment. do you know any way for not overwriting the timeout which already set in each environment.
You can leave the default timeout in place, and you don’t need to overwrite it with a different value.
hi Chris, I have an Azure function .net code deploying through Azure pipeline. How do I edit the host.json? When i try to edit, it says that i cant edit because it is deployed through CICD. Where should i keep host,json in my project package? I tried to keep in root folder of project package, but if did not picked
You’ll need to modify your build pipeline to perform any modifications to the host.json file.
Hi Chris Pietschmann, I have a QueueTriggered function app developed in Python, running under Premium Plan and in host.json I have given timeout value to 2 hours, but it was failing with error “Timeout value of 02:00:00 was exceeded by function: Functions.myFunction”. So I changed 2 hours to 4 then to 6 hours as there continued to get same timeout issue.
Later on I have given timeout to 23:59:59 ( I know it sounds ridiculous, but with frustration I gave this much value). But to my surprise still I get error: Timeout value of 23:59:59 was exceeded by function: Functions.myFunction
Can you suggest me any solution here?
Have you tried troubleshooting your code and ensuring there isn’t any kind of infinite loop condition occurring?
Hi Chris Pietschmann, We are running a function under app service plan and added function timeout as ‘-1’. But it is giving function timeout exception after 30 Min. Our target framework is 3.0.
It’s possible the change you are making to the `host.json` file is getting overridden. How are you modifying the `host.json` file? If you are modifying the `host.json` file in the Azure Function App and then deploying your code it would be getting replaced with the code deployment.
Chis thanks for your various articles – I ended up here from you review of how to decide which service to use func apps, webjobs etc- In that article you mentioned the ability to share an app service plan – which I have seen when create app-x resources – what does this exactly mean ? If I create multiple func apps, webjobs etc I will be charged at that rate – total – or will I be charged the multiple – for example if I have 2 function apps under a premium tier which is at 150/mo – will I be charged a total of 150 or 300 ? I realize there are other considerations in the pricing matrix this is just for simplicity
With App Service Plan you are billed by the number of instances of the App Service Plan. Be default an App Service Plan has only a single instance, and you will only pay for that 1 instance if you host multiple Function Apps, App Service Web Apps, etc on that same plan. Think of an App Service Plan as a VM, or with scaling to multiple instances as multiple VMs. You will pay for the number of instances of the App Service Plan, not the number of apps hosted on that plan.
access denied to edit host file? 🙁 any ideas? I looked on stackoverflow
Did you deploy a precompiled function app? That could be why.
Is function timeout applicable on Azure timer triggered functions as well ?
Yes
I have multiple functions in my function app
For some of them I want timeout to be 5 min and for one of them i want to keep it around 2hr
Will it be possible to keep diff timeout for fun in same fun app?
No, the execution timeout is for the Function App, not the individual functions.
guys , i want to create a simple function to trigger every minute and in that function i want it wait for 5 minutes. Just like in bash sleep for 5 minutes and done. Please tell me how can i do this . i just want to monitor the functions behaviours that is my purpose for making the function to wait for 5 minutes.
Hi chris I have create simple trigger azure function from portal in .NET 6 with App service plan when I trigger this function url from postman so getting timeout after 4 min in code just add 5min sleep can you suggest here
Are you sure it’s a regular App Service Plan and not a consumption based App Service Plan? Also, you may need to update the timeout config to make sure it’s what you need.
Hi Chris,
How can I disconnect from the domain connected through Powershell in Azure functions
I’m note sure I understand what you’re asking. What do you mean by “domain”?
Hello Chris, a pleasure, I have a selenium script that I am executing in a function app through a docker image, the entire script lasts approximately 20 minutes, a vm is not optimal for my use case because it has a higher cost, Is it optimal to use app function for this use case? What would you recommend in the future? in terms of saving money and ideal implementation?
If you can’t make your script / function run within the timeout limit, then the best course of action is to pay the cost for a different hosting option, or break up the Function into multiple smaller functions. You my want to look into Durable Functions, or simply re-architect your function into a more granular instead of a monolithic one.
Can we parametrize this property(functionTimeout) to use values from app configuration, or any other way?
You can not parameterize the settings configured within the host.json file. The reason for this is the Function Runtime Host is reads the host.json when it starts up the app. This occurs before the app settings or other parameters are even read or any application code is executed.