skip to Main Content

I have a fair bit of experience with Azure Functions and I’ve never noticed had issue before, but a timer function I currently use is causing me a bit of a headache.

I use the CRON expression: 0 */18 * * * * which to me means "run every 18 minutes". Generally it follows that pattern but recently it has developed a mind of its own. I write to Application Insights when it is invoked and these are the minutes between each invocation the other day:

18, 4, 4, 16, 18, 18, 6, 4, 14, 18, 18, 6, 9, 9, 18, 18, 6, 13, 18, 18, 18, 6, 16, 4.

Obviously, I expect them to all be 18, but it looks like it’s like this every day. Some invocations happen as soon as 2 minutes after. I checked the status config at one point to see what it says and this was the contents:

{"Last":"2023-07-20T10:54:00.0084847+00:00","Next":"2023-07-20T11:00:00+00:00","LastUpdated":"2023-07-20T10:54:00.0084847+00:00"}

As you can see it ran and 10:54:00 and then scheduled the next to run at 11:00:00. Not exactly 18 minutes!

Extra info – the scheduled action takes about 3 minutes to run and the timeout is set to 10 minutes, but it never reaches that. I also deploy the Azure Function using Visual Studio as a Zip deploy. The Function App is runtime version 4.

1

Answers


  1. I tried with the same CRON expression 0 */18 * * * *:

    enter image description here

    Only one execution was irregular, and all other executions were regular with 18 minutes difference.

    enter image description here

    The irregularity in executions could be because of the function app is scaling out to multiple instances, and only one instance of the timer-triggered function is running across all instances.

    • Check if there are any errors or exceptions that could be causing the function to fail, and the timer trigger doesn’t retry after a function fails.

    • Re-validate the configuration of your function app and ensure that it is set up correctly. Additionally, you can investigate the

    • Try to test the function with different CRON expression (Ex: 5min [0 */5 * * * *]).

    • As @Anand Sowmithiran mentioned, validate timezone of your function app.

    If still the issue persists, try using a Timespan value instead of a CRON expression to specify the time interval between each function invocation.

    As mentioned in the document, to maintain regular frequency in function execution:

    • Need to follow the below mentioned pattern while configuring CRON expressions:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search