Alert This post is over a year old, some of this information may be out of date.

Why does your timer trigger Azure Function run at unforeseen times?

Why does your timer trigger Azure Function run at unforeseen times?

Has it ever happened that your timer triggered Azure Function was running on unforeseen times? We had it for two functions, and could not immediately find out where or why this was triggered more than once an hour.

Timer function running multiple times per hour
Timer function running multiple times per hour

One of the functions should run once every hour, but as you can see, sometimes it runs more. Between 10-11, it ran three times.

What is the issue?

While checking the timer function documentation, I saw this alert about the runOnStartup property:

runOnStartup property warning
runOnStartup property warning

Info: Due to this property, our function automatically started each time the service was restarted, scaled out, … Documentation can be found here: Timer trigger for Azure Functions documentation.

The solution

As the documentation specifies, you should not use this functionality in production. Best is to remove this property or set it to false.

Timer function running only once an hour after updating the property
Timer function running only once an hour after updating the property

It might be that in some cases, you want this kind of functionality. In that case, you can leave it as is, and then you know why it happens.

Comments

Back to top