I recently created an Azure function that utilized a Timer trigger. This super useful feature enables the function to run periodically on a schedule of your choosing, such as once a day, once an hour, only on Tuesdays, etc. These functions make use of CRON expressions, which are a standard way of expression time schedules in a succinct way. Each number in the series represents an hour, day, minute, and so on, and they support other simple characters for more advanced timing patterns. In other words, they’re sort of like regex, but for time scheduling.
You can see an example below:
However, I quickly ran into an issue with this configuration. After I deployed my timer function to a Windows Function App (Not Linux), it simply wouldn’t execute no matter what I tried, and the logs were cryptic to say the least.
Well, it turns out I was using a popular site called crontab to create my expression. The problem here is that this site (and many others) utilize Unix CRON expressions, which are only FIVE characters. However, if your Azure function is hosted on a Windows App, it wants the expression formatted with a SIX character approach. This is very important – the function will not run with the wrong format.
Again, my expression that would NOT work (on Windows):
My expression that DID work:
Note that if you are hosting on a Linux Function App, the 5 character format should work. This gets especially confusing if you are migrating from one type of app to another.
Tracking down the solution to this fail-silently problem caused me a huge headache, hopefully this helps you avoid the same issue.
As a side note, Timer Functions run on UTC time by default, so if your function isn’t executing when you expect, it might be because its environment is running in UTC time, so adjust your expression to match.
You can supposedly change this configuration to a local time zone by adding a WEBSITE_TIME_ZONE configuration on the app settings and set a value such as “Eastern Time Zone”, but honestly I have had very hit or miss luck getting this to work. I find it easier and more reliable to just write my timer trigger expressions in UTC time and leave it that way.
Moral of the story: Check the format of your CRON expression if your timer function is not running! And make sure that you’re considering UTC time.