Azure Timer Trigger

 

Azure Timer Trigger

Create a new Azure Function Project: Open your code editor and create a new Azure Functions project.

Add a Timer Trigger Function: Add a new function to your project, and choose the "Timer trigger" template.

Edit the TimerTrigger function: Update the function code to fit your needs.

https://crontab.cronhub.io/

public class Timers
{
    private readonly ILogger _logger;

    public Timers(ILoggerFactory loggerFactory)
    {
        _logger = loggerFactory.CreateLogger<Timers>();
    }

    // Cron expression * * * * *
    // minutes hour dayOfTheMonth month dayOfTheWeek
    // Example */5 * * * * (Runs Every Five Minutes)
    // Example 0 * * * * (Runs Every One Hour)
    // Example * */1 * * * (Runs Every 1 Minutes)
    [Function("TimerTrigger")]
    public void Run([TimerTrigger("*/5 * * * *", RunOnStartup = true)]
        TimerInfo myTimer)
    {
        _logger.LogInformation($"C# Timer trigger function executed at: {
                DateTime.Now}");

        if (myTimer.ScheduleStatus is not null)
        {
            _logger.LogInformation($"Next timer schedule at: {
                myTimer.ScheduleStatus.Next}");
        }
    }
}




Raviteja Mulukuntla

Hello Viewers! My name is RaviTeja Mulukuntla and I am a senior software engineer working in a reputed IT firm. I like sharing my professional experience and knowledge skills with all users across all the Digital Platforms.

Previous Post Next Post

Contact Form