Search code examples
azurecronazure-functionstimer-trigger

Azure function not triggering on specified time


I've been looking around for a solution to an issue I am having. I looked at various posts on the same topic but none of them solved my issue, hence creating a new thread for this, so kindly read it once before marking it as duplicate.

I've created a C# HTTP Timer Trigger Function on Azure and specified CRON timing, but it is behaving weirdly.

This is my function.js

X

My cron expression: 0 */60 15-3 * * 1,2,3,4,5,6

My function will trigger every 60 minutes between 03:00 PM and 03:00 AM, only on Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday

But to my surprise it is triggering from 3:00 AM to 3:00 PM, and I am unable to understand why.

I followed the accepted answer of Azure function is not triggering on scheduled time post but still it is behaving the same.

Note: I have not enabled internal logging but I am maintaining a separate log in a different folder on Azure.

Edit 1: I just noticed that, if my function has been scheduled to run within the day i.e. if hour has been set anywhere between 0-24, it works properly but if hour has been set in such a way that it goes over the day i.e. 15-3 (in my case) its behavior changes completely and it runs from 3-15 and not the other way around.


Solution

  • */60make non sense. Use 0 And following cron logic make two records like:

    0 0 0-3 * * 1,2,3,4,5,6
    0 0 15-23 * * 1,2,3,4,5,6
    

    If you want to make them as only one record you can try this:

    0 0 0-3,15-23 * * 1,2,3,4,5,6
    

    If this do not work you should use record like:

    0 0 0,1,2,3,15,16,17,18,19,20,21,22,23 * * 1,2,3,4,5,6