Showing posts with label Azure functions. Show all posts
Showing posts with label Azure functions. Show all posts

Azure Functions timeout

Everything about function app timeout

 

Issue:

·       Timeout value of 00:05:00 exceeded by function?

·       What is azure functions timeout?

·       What is azure functions execution timeout?

·       What is default timeout in azure function?

·       Consumption plan timeout?

·       Premium plan timeout?

 

Solution:

What is timeout?  In business logic language, a timeout is a specified period of time that will be allowed to complete an operation and if that operation doesn’t complete within specified period of time then it will throw some exception. Timeouts allow for more efficient usage of limited resources without requiring additional interaction from the agent interested in the goods that cause the consumption of these resources.

A common example is your smart phone turn off backlight after a certain time when idle which you can set.

Similarly, Azure has set the timeout for function app and it is very important to understand it as you can develop/write your business logic and optimize it accordingly.

In Azure functions, timeout means if your business logic or code should be optimized enough to complete with timeout duration otherwise it throws exception like “Timeout value of 00:05:00 exceeded by function”


In Azure functions, timeout varies according to hosting plan and runtime versions.

Azure functions have 3 hosting plans,

  • Consumption plan (Dynamic plan)
  • Premium plan (Elastic premium plan)
  • App Service plan (Dedicated plan
And as of now it has 3 runtime versions,

·       1.x

·       2.x

·       3.x

Where 1,2 and 3 is the major version and x stand for minor version e.g. 2.09234.

Now we know what azure functions execution timeout is? hence we should focus on

·       Default timeout,

·       maximum timeout

for each hosting plan.

You can check this information in the below list.

Azure Functions timeout











That means if you see exception like “Timeout value of 00:05:00 exceeded by function” then you quickly need to check if your function is hitting the default timeout.

Here you have 2 options,

1.      Investigate why your code execution is taking that much of time and optimize your code

2.      Increase the default timeout.

For first case you better know how to optimize the code.

How to modify the default timeout

Azure functions timeout value is stored and handled in host.jsonfile and attribute name is functionTimeout

{

    "functionTimeout": "00:05:00"

}

 

functionTimeoutindicated the timeout duration for all the functions and not for the single function.

You can update the default timeout value, save it, and test your function again.

In dedicated app service plan there is no limit but you should keep a fixed upper bound limit as unlimited timeout can have some disadvantages like your execution will keep executing and you will have to pay for it.

For unlimited timeout you can use -1

{

    "functionTimeout": "-1"

}

Important note

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.


Function timeout at function level

We know now that we can set function timeout in host.json but it is for all the function inside it. What about setting timeout for one or 2 function only.

While developing the functions from Visual Studio, you can now set the timeout at the function level.

Adding the attribute [Timeout("00:00:10")], above the function definition would set the timeout value for the function.  more details.

I did test the function executions to confirm that it doesn’t affect executions of other functions in the same function app.

With the test deployment I made – I deployed multiple function to the Function App on Azure, with only one of them (say function A) having the timeout set. While executing the functions, we see that A stops after the threshold timeout value and the others continue as expected.

Imp Note: This is for C# language only.

Azure Functions timeout


Output:

Azure functions timeout





Hope this helps. Please let me know if you have any query

References:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale

https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json#functiontimeout


Azure Functions

  • What we can do?
  • Use of Azure Function 
  • Azure function real life scenario.







This Video provides an overview of Azure functions aka Function App



This Azure function app is down for maintenance


Issue:

·       Host is offline?


Solution:

Sometime when you browse your Azure functions you see this message,

This Azure function app is down for maintenance

Mostly this issue happened after deployment.

The reason for this issue is, app_offline.htm file.

You can find this file inside WWWROOT folder of your KUDU site.

When you deploy your function app or app service, Azure create a temporary app_offline.htm file before starting the deployment. This happens to avoid file lock issue.

Once deployment is successful then KUDU automatically delete this file.

Your app appears offline during the deployment.

Sometimes due to some exception or issue app_offile.htm file is not deleted after deployment which ended up with this issue.

To resolve this issue, you can go to KUDU site-> WWWROOT folder and delete this file.

If you'd like to turn this behavior off, please add an SCM_CREATE_APP_OFFLINE App Setting to your app and set the value to 0.




Azure Functions No Access


Issue:

·       I am not able to see any function inside my azure functions.

·       I can see “No Access” message.


Solution:

Sometimes when you open your Azure Functions you see “No Access” message and not able to access any function inside your function app.

Azure Functions No Access


The most probable reason for this issue is your RBAC role assignment.

If you have readerrole assigned in your function app or in that resource group, then you will not able to able to see anything which can be modified. The portal will display (No Access)


A user with “reader” role can view some setting in the function app portal but can’t update/modify anything.

To update/modify something you should have write access.

You can check with your admin or subscription owner who can assign you enough access.

Refer below URL for more details,



Subscribe to Azure App Services Announcements 


is there any Azure outage?

Issue:
·       How can I get the auto notification for any changes/update in Azure App Service?
·       Can I get email/notification for any new feature in azure app service?
·       How can I know about breaking changes in azure app service?
·       Is there any Azure outage going on?

Solution:

I discovered how we can get automated notifications from Azure App Services team on the latest announcements. So if you ever wondered about the question “How can we be notified for any new announcement(Major) in Azure App Service?” – please continue reading.

As you are aware, Azure App Service team is continuously enhancing the product based on user’s feedback/requirement/Issue but how to get the notification for the new changes or ongoing issues.
Below are the steps to proactively get notified about the latest announcements sent by Azure App Service Engineering team.

How to subscribe to App Service Announcement:

Step 1: click on below URL which is for both “web app” and “Azure functions”.



Step 2:  click on Watch icon. You may have to login. If you don’t have GitHub account please create one.



Step 3: Once you click on Watch, it will convert to Unwatch


That’s all, you are done.

Now you will start receiving communication for all the Major enhancement.

You can see the list of all announcement,



If you want to know about the Azure outage in any specific reason then you can check below URL,
Azure team keep updating their status on this page which helps users to understand if any issue is going on or not,



I believe this helps. Please share your query/feedback.

Other useful references,


Issue: Azure function is throwing one of the following exceptions
·       Unable to retrieve Functions Keys
·       We are not able to retrieve the keys for function
·       The function runtime is unable to start.
·       Function host is not running.
·       Internal Server error.
·       Service Unavailable.


Issue: Azure Functions: The Consumption pricing tier is not allowed in this resource group



Issue: Disable Azure functions