Azure Functions: timer job doesn’t fire when it should

Our function should have been triggered by timer, but wasn’t…

We recently encountered a problem in Azure Function App service. We have created a Function that should be triggered on schedule, once every day. It’s a typical case for use of a [TimerTrigger]. For example, [TimerTrigger("0 0 8 * * *")] should start the function every day at 8:00 AM UTC.

The setup was along these lines:

However, we noticed that in some environments, the timer did not trigger the function at all when it was expected. So, what was the problem, and why it occurred only in some environments and not all of them?

Diagnosis and solution

It turned out, that the problem was in the type of App Service Plan that we used in our development environments.

Specifically, we used the following App Service Plan tiers to keep the cost of development environments low:

  • Free tier of App Service Plan
  • Shared tier of App Service Plan

In those tiers, the Function App cannot have the “Always on” setting enabled. So, the application can get unloaded when it’s idle. When that happens, timer triggers are not functional.

How can this be fixed? We can use a different Service Plan:

  • Basic tier of App Service Plan and the Always On flag enabled on a Function App. This works, but Basic tier has a noticeable, constant monthly cost. It might be an unnecessarily costly solution for development environments.
  • Consumption plan. That one was ideal. It has zero constant cost (it’s totally in pay-as-you-go model), and it supports timer triggers just fine.

A more general solution

We encountered one of the few possible causes for the problem of timer triggers not firing.

If you are stuck with a similar problem, the best way to start debugging is probably to consult an official Wiki document for troubleshooting timer-triggered function not firing. This one is pretty hard to find via search engine, but it exhausts the topic and is certainly worth reading.

Leave a Comment