I have an Azure webjob that was created as a console application and published to azure via Visual studio.
When I login to the portal, I can see the web-job is running, but I want it to run every 1 hour.
I have an Azure webjob that was created as a console application and published to azure via Visual studio.
When I login to the portal, I can see the web-job is running, but I want it to run every 1 hour.
Two options:
use Hangfire and schedule to run every one hour:
RecurringJob.AddOrUpdate(() => Console.WriteLine("This job will execute once in every minute"), Cron.Hourly);
Change the Web Job to Azure Functions and use the time trigger:
public static void Run([TimerTrigger("* 0 */1 * * *", RunOnStartup=true)]TimerInfo myTimer, TraceWriter log)
{
//code
}
more info:
https://github.com/HangfireIO/Hangfire
https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-scheduled-function
Use a "triggered/scheduled" WebJob instead of a continuous one.
https://learn.microsoft.com/en-us/azure/app-service/webjobs-create#CreateScheduledCRON