Timer trigger Azure function - How to get datetime details of the last successful execution?

Viewed 866

What is the difference between TimeInfo.ScheduleStatus.Last vs TimeInfo.ScheduleStatus.LastUpdated?

What want to know is the datetime details of last successful run of my timer trigger Azure function? not just when it was last run regardless of outcome (success or failure).

1 Answers

What is the difference between TimeInfo.ScheduleStatus.Last vs TimeInfo.ScheduleStatus.LastUpdated?

To know this, you can go to the github to have a look of the comment of the source code:

https://github.com/Azure/azure-webjobs-sdk-extensions/blob/a3a5a49a64f3592c1eb7c1296086dc83c2011e96/src/WebJobs.Extensions/Extensions/Timers/Scheduling/ScheduleStatus.cs#L16

and this source code of azure-webjobs-sdk-extensions:

https://github.com/Azure/azure-webjobs-sdk-extensions/blob/dev/src/WebJobs.Extensions/Extensions/Timers/Listener/TimerListener.cs#L97

Gets or sets the last recorded schedule occurrence

So the 'Last' means the time you last trigger the function, no matter success or failure.

And

    ScheduleStatus = new ScheduleStatus
    {
        Last = adjustedInvocationTime,
        Next = _schedule.GetNextOccurrence(adjustedInvocationTime),
        LastUpdated = adjustedInvocationTime
    };

You can find the 'Last' and 'LastUpdated' is get from the same value.

If you want to get the success time of last success with build-in value, then there is no way. You can use 'FunctionResult' to return whether the function is success. If you success trigger the function, then return FunctionResult(true).:)

Related