So I have created a SimpleSchedular using Quartz.Net in C# as below -
I have created this inside WebApi
project.
// Grab the Scheduler instance from the Factory
NameValueCollection props = new NameValueCollection
{
{ "quartz.serializer.type", "binary" }
};
StdSchedulerFactory factory = new StdSchedulerFactory(props);
IScheduler scheduler = await factory.GetScheduler();
// and start it off
await scheduler.Start();
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<IDGJob>()
.WithIdentity("job1", "group1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartNow()
.WithSimpleSchedule(x => x.WithIntervalInMinutes(5).RepeatForever())
.Build();
// Tell quartz to schedule the job using our trigger
await scheduler.ScheduleJob(job, trigger);
This worked like a charm in localhost BUT once I deployed it to Azure it did not do anything.
So I did some googling and found that Azure works on Eastern Standard Time -
var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
var cronScheduleBuilder = CronScheduleBuilder.DailyAtHourAndMinute(19, 10)
.InTimeZone(timeZoneInfo);
and changed the Scheduler as -
ITrigger trigger = TriggerBuilder.Create()
.StartNow()
.WithSchedule(cronScheduleBuilder)
.Build();
I also tried UTC format as well.
BUT still nothing is working.
I even used RoleEntryPoint
class but result again the same.
Does this Quartz really works on Azure or am i missing anything.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.