Updated March 16, 2023
Introduction to Azure Function Timeout
This article provides an outline of Azure Function Timeout. Basically, Azure provides different types of features and functions to the user; the timeout is one of the functions used to specify the execution time of a specific function, or we can say that, as per our requirement, we can set the timeout duration to deploy the function. Normally the timeout function has one minute default time, but as per our requirement, we can extend the time up to nine minutes which is 540 seconds.
Key Takeaways
- The azure function provides the features to write less code.
- The azure function does not require large infrastructure, which means we can use less infrastructure.
- By using the Azure function, we can save the cost of hosting applications.
- One more important feature is that it provides the cloud infrastructure which provides up-to-date resources to keep running hosting applications.
What is Azure Functions Timeout?
We just need to select a hosting plan for your app when creating a function app in Azure. There are three fundamental facilitating plans accessible for Sky blue Capabilities: Dedicated (App Service) plan, Premium plan, and Consumption plan. Virtual machines running Linux and Windows are both generally available (GA) for all hosting plans.
The function timeout property in the host.json project file specifies the timeout duration for functions in a function app. This property is only applicable to the execution of functions. The function must return or respond within the timeout duration after the trigger initiates execution. Improve Azure Functions’ reliability and performance for more details.
Azure Functions Timeout Configuration
Let’s see how we can configure the timeout function in Azure as follows:
Normally Microsoft recently updated this feature, which that means as per user requirements, they can configure the function timeout. For configuration, there are two different ways; in the first way, we can directly make changes inside the host.json file, and in the second way, we can directly update the Azure portal.
1. Configuration of host.json file
In this file, we need to add the function timeout for configuration with the help of the below syntax.
"functionTimeout": specified minutes or seconds
Explanation:
- In the above syntax, we can see two parameters. first is the function name, and in the second parameter, we need to set the time.
Examples:
"functionTimeout": "00:15:00"
Suppose let’s consider if we need to set the function timeout to 15 minutes; then, we can use the above statement.
"functionTimeout": "00:10:00"
Similarly, if we want to set the function timeout to 10 minutes, then we can use the above statement.
If we want to set the hosting time for a second, then we can use the below statement.
"functionTimeout": "00:00:30"
An Azure Functions App’s global configuration file is host.json. This indicates that all functions hosted within that Azure Functions App will be affected by the configuration settings in this file. It is not stored in the files for any particular Azure Function because it is a global configuration file for the Function App. All things considered, the “host.json” record dwells inside the fundamental www-pull organizer for the Capability Application as it’s facilitated inside the interior Application Administration Plan.
2. How can we update the host.json file on the Azure portal
For accessing and updating the host.json file, first, we need an application service editor where we host the application of the Azure functions; if we are using the CI/CD pipeline, then it is not recommended.
So first, open the Azure function application, from the list, we need to select the App service editor command, which is present under the development tool, as shown below screenshot.
In the next step, we need to open the app service editor with a new tab, where we can observe Azure provides the same kind of UI as VS code. So here, just click to host.json file, which is present under the root folder; after clicking on the host.json file, we get a blank screen means it is the first time this is empty, as shown in the below screenshot.
So as per our requirement, we can set the timeout; here, we will set the 5 minutes as shown below in the screenshot.
It is essential to be aware that the App Service Editor will automatically save every change. This indicates that using the App Service Editor in a Production environment necessitates extra caution. The App’s performance and downtime could be harmed by any typos or incorrect configurations. For this reason, please use the App Service Editor at your own risk. If you’re working in a Dev or Test environment, you probably won’t have any problems because you can easily go back and fix any errors.
Azure Long Running Functions
When we are executing the Azure function for the long run, then we have a default 5 minutes default time, which we can update as per our requirement. When we talk about the running function it takes better time for execution of Application for service as well as web, and there is no limitation for execution time.
If we have different types of dependencies on a function, then it is loaded either explicitly or implicitly. Normally it is implemented with the help of the durable functions of azure. With the help of a durable function, we can easily implement the long-running process either in Asynchronous HTTP or monitoring patterns.
Azure Function on Consumption Plan
Basically, Azure provides different types of plans such as Premium Plan, Dedicated Plan, and Consumption Plan. Some are free, and some are paid.
Basically, the Consumption plan automatically scales and is only applicable for computing resources of running functions. In the consumption plan, instances of a function are dynamically added and removed on the basis of the incoming object or we can say that events. It contains the default hosting plan; in this plan, we need to pay when we are executing functions.
Value
- Value is nothing but the maximum amount of time that we need to specify for the function timeout.
- Basically, the function timeout value is used for the HTTP request-response, or we can say that it acts as an azure load balancer with some default time; if we want to increase it, then we can increase it.
Conclusion
From the above article, we have taken in the essential idea of the Azure function timeout and the representation of the Azure function timeout. From this article, we saw how and when we use Azure function timeout.
Recommended Articles
This is a guide to Azure Function Timeout. Here we discuss the introduction, configuration, azure long running functions, and value. You can also look at the following articles to learn more –