TtimerInfo.Schedulestatus.Next is not showing next trigger time

Tanuja Valluru 20 Reputation points
2023-12-08T11:10:18.8+00:00

It is showing executing time only not the next time when it triggers, how can I get next time when timer trigger works

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,304 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,791 Reputation points
    2023-12-08T11:24:25.86+00:00

    @Tanuja Valluru Thanks for reaching out.

    Please refer to previous discussion here.

    <SNIP>

    ScheduleStatus is a structure persisted to storage to aid in detection of past due schedule invocations. As the class xml doc says, Next is “the next schedule occurrence”. So on startup, if schedule monitoring is active, we’ll load the ScheduleStatus (code here) and use Next to determine how long to wait before the next invocation (Next - Now). Thus, when this duration expires, we’ll invoke the function and Next will equal Now.

    So Next isn’t the next schedule time from the current invocation – it’s the value that was used to determine when to invoke the current invocation. The naming of the properties of ScheduleStatus are from the perspective of the scheduler, not from the perspective of the current invocation. This is by design, though I can appreciate why there may be some confusion.

    If the goal is to determine the next expected invocation from the time of the current invocation, the schedule can be used as follows to determine that:

    public static void CronJob([TimerTrigger("*/15 * * * * *")] TimerInfo timerInfo)
    {
        var schedule = timerInfo.Schedule as CronSchedule;
        var next = schedule.GetNextOccurrence(DateTime.UtcNow);
    
        . . .
    }
    

    </SNIP>


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.