Azure timer function does not fire

Dave Gray 586 Reputation points
2022-10-12T07:54:27.47+00:00

Hello,

I have just published a new Azure function, which runs fine in VS2022 in debug but simply will not fire as per the trigger CRON expression. I had this CRON in settings
but have hard-coded the value in the method signature.

I typically write log info to a SQL table so I can see progress etc, however as this does not even start then I'm not getting that. I just started writing to ILogger but it's not much help if the function does not start.

My CRON expression is "0 15 10 * * *" which I understand as 10:15 (daily) based on the Azure region my function is in - in this case north Europe. As an aside, can anyone recommend a good/reliable CRON checker/generator site? I find some sites will say an expression is invalid whereas others parse it to a valid format.

Thanks

Code if it's helpful

public class GetLogicMonitorDevices  
    {  
        [FunctionName("GetLogicMonitorDevices")]  
        public void Run([TimerTrigger(scheduleExpression: "0 15 10 * * *")]   
            TimerInfo myTimer, ILogger log)  
        {  
            var clock = new Stopwatch();  
            clock.Start();  
            log.Log(LogLevel.Information, $"Starting at {DateTime.Now.ToString()}");  
            new BL().GetData(Guid.NewGuid(), RunSource.Timer);  
            log.Log(LogLevel.Information, $"Starting at {DateTime.Now.ToString()}");  
            log.Log(LogLevel.Information, $"Elapsed milliseconds {clock.ElapsedMilliseconds}");  
            clock.Stop();  
        }  
    }  
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2022-10-13T04:34:09.04+00:00

    @Dave Gray Thanks for reaching out.

    Azure Functions uses the NCronTab library to interpret NCRONTAB expressions. NCRONTAB expression supports both five field and six field formats. The sixth field position is a value for seconds which is placed at the beginning of the expression. For more details you can refer to this document. Therefore, some of the sites which don't support six field format will make your CORM expression as invalid.

    Your CORN expression 0 15 10 * * * means that it will occur at 10:15 every day. The default time zone used with the CRON expressions is Coordinated Universal Time (UTC)

    You can refer to below NCrontab Expression Tester: https://ncrontab.swimburger.net/
    Alternative: https://crontab.guru/

    Feel free to get back to me if you have any queries or concerns.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


1 additional answer

Sort by: Most helpful
  1. Stefano Demiliani 166 Reputation points MVP
    2022-10-12T12:58:48.83+00:00

    10:15 every day should be: 15 10 * * * (3 stars)
    For info:
    https://en.wikipedia.org/wiki/Cron

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.