简体   繁体   中英

Azure functions - Functions host is not running

I keep getting an error 503 on my health checks for my azure functions, it says error 503. Functions host is not running. It's very inconsistent and only happens once every few days, I'm on the consumption plan but looking at whether a premium plan would fix the issue.

In Azure Functions, 503 service unavailable causes for the reasons like:

  • Function host is down/restarting

  • Platform issue due to the backend server not running/ allocated

  • Memory leak/issue from the code causing the backend server to return 503

To get some insights about the function host related issues, take a look into the " Diagnose and solve problems " blade in the Function app and select the " Function app down or reporting " detector. This detector will show all the diagnostic information about the function app and its infrastructure.

在此处输入图像描述

  • 503 service unavailable comes sometimes when the function takes more than 5 minutes to return an HTTP response in consumption plan. 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. For longer processing times, use Azure Durable Functions async pattern. Refer to this link .

  • We should not change the app settings frequently in the production environment. If you update the app settings, the app will be restarted. In this cases, you will get 503 error. In order to avoid this, you can use the slot feature


Function host is not running

This issue happens due to invalid host.json . To diagnose, it's best to look at the function host logs from the log stream in Azure Portal.

Few errors and resolutions of this kind of error are:

  • If you have any startup.cs class, check if any error available where the errors were logged in Application Insights.
  • One of the reason is a missing app setting. Ensure you publish local settings as well.

If it didn't help then one of the reason could be platform issue and to confirm this we need to look into the backend logs on what was happing during that time resulting in 503 errors.
You can create the support ticket with Microsoft to assist you further.

According to this thread , one possible cause of 503 service-unavailable responses is when the service consumes more memory than what is available under the consumption (serverless) plan, causing the service to be evicted. Switching to a dedicated hosting plan can fix this issue. According to Microsoft's documentation , it appears that the function is allowed a maximum of 1,536MB of memory at one time. Of course, it could also be the case that your function is exceeding any of the other service limits associated with that plan, so my advice would be to add instrumentation and code defensively.

Availability zone (AZ) support isn't currently available for function apps on Consumption plans.

In Consumption Plan, the functions apps SLA is 99.95% of the time.

It won't failover to a different geo region, no matter the hosting SKU. Use Traffic Manager to achieve that level of redundancy.

Needless to say, all resources your function depends on need to exist in the 2nd region as well (SQL instances, Redis, Event Hubs, ...). You are responsible for keeping state consistent across regions (think Azure SQL auto-failover groups ).

One notable exception is Cosmos DB, which (if configured ) can have automagically-managed replicas in multiple regions. Your function will always use the same connection string.

The best you can do (IMHO) is to define the data redundancy as Geo-zone-redundant storage and let Azure handle this for you.

Got 503 after redeploying an Azure function.

Turned out the Python version had defaulted to 3.6, updated to 3.9 and started working.

I was using terraform and github actions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM