How to calling a function in Azure Continuous Webjob every n minutes
I have a function that is in a continuous Azure WebJob and that function is required to be called once every 5 minutes.
Code in Program.cs
static void Main() { var config = new JobHostConfiguration(); if (config.IsDevelopment) { config.UseDevelopmentSettings(); } var host = new JobHost(config); host.Call(typeof(Functions).GetMethod("StartJob")); host.RunAndBlock(); }
Code in Function.cs
[NoAutomaticTrigger] public static void StartJob() { checkAgain: if (DateTime.Now.Minute % 15 == 0 && DateTime.Now.Second == 0) { Console.WriteLine("Execution Started on : " + DateTime.Now); //Execute some tasks goto checkAgain; } else { goto checkAgain; } }
Add comment