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}");
}
}
}