Why did my Function App stop working?


We had a customer the other day whose Function App stopped working. He was using a blob trigger and it worked fine for a while, but at some point during the overnight hours, it just stopped working. Naturally, he assumed something in Azure was broken and he opened a support case. As it turns out, nothing was broken. The Function App shut itself down due to inactivity during the overnight hours. You might be wondering why this would ever happen. Read on and you’ll find out.

Hosting Options for Function Apps

When you create a Function App, you have two options for hosting them; a Classic and a Dynamic App Service plan. This post applies to the Classic App Service plan Function Apps only. If you created your Function App in a Dynamic App Service plan, you can move on because this information doesn’t apply to you. If you don’t know which type of App Service plan your Function App is using, here’s how you can find out.

  1. Open your Function App in the Azure portal.
  2. Click on Function App Settings at the top of the Function App blade.

 

image

 

  1. Scroll to the bottom of the page and click on Go to App Service Settings.

 

SNAGHTML64a9d71

 

  1. Check the App Service plan in the Essentials part to see what type of plan you are in. In the image below, you can see that I am in a Dynamic App Service plan. If you don’t see Dynamic, you are in a Classic App Service plan and the rest of this post does apply to you.

 

image

 

The Problem

Under the hood, a Function App runs just like a Web App, and configuration settings for a Function App mirror those of a Web App, including a setting called Always On. This setting is designed to ensure that your app always remains running. If Always On is turned off, your app will terminate itself after a prolonged period of inactivity. For a Web App (or for a Function App that uses an HTTP trigger), this may not matter because when the URL is hit, the app will spin up again and all will be good. However, if you have a Function App that doesn’t use an HTTP trigger (perhaps something like a Blob trigger) and it closes down due to inactivity, it will stop working. In order to make it work again, you have to open it in the Azure portal and manually invoke it to spin it up again.

For this reason, when you create a Function App in a Classic App Service plan, we enable Always On so that your Function App will always be running. However, you do have the ability to turn off Always On, and if you do, your app may shut down after some inactivity. For that reason, if you want to ensure that your Function App is always running, you should leave Always On enabled.

Note: Always On is only available in the Basic and higher pricing tiers.

Here’s how you can ensure that Always On is enabled in your Function App.

  1. Open your Function App in the Azure portal.
  2. Click on Function App Settings at the top of the Function App blade.
  3. Scroll to the bottom of the page and click on Go to App Service Settings.
  4. In the Settings blade, scroll down and click on Application Settings.

 

image

 

  1. In the Application Settings blade, make sure that the Always On setting is set to On.

 

image

 

Once you enable Always On, your app will remain running even when it is idle for a prolonged period of time.

Comments (1)

  1. dafna says:

    I created my function using the simple wizard, with “Consumption plan” and not “App Service plan”.
    encountered the same behavior that the function stopped working.
    Seems that this setting “Always on” doesn’t exists…
    Any idea why…?

Skip to main content