简体   繁体   English

Quartz.Net 调度程序在 Azure 中不起作用

[英]Quartz.Net Scheduler not working in Azure

So I have created a SimpleSchedular using Quartz.Net in C# as below -所以我在 C# 中使用 Quartz.Net 创建了一个 SimpleSchedular,如下所示 -

I have created this inside WebApi project.我在WebApi项目中创建了这个。

// 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.这在本地主机中就像一个魅力但是一旦我将它部署到 Azure 它什么也没做。

So I did some googling and found that Azure works on Eastern Standard Time -所以我做了一些谷歌搜索,发现 Azure 适用于东部标准时间 -

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.我也尝试过 UTC 格式。

BUT still nothing is working.但仍然没有任何工作。

I even used RoleEntryPoint class but result again the same.我什至使用RoleEntryPoint class 但结果再次相同。

Does this Quartz really works on Azure or am i missing anything.这个石英是否真的适用于 Azure 或者我错过了什么。

It works, but there's a high chance your web app is going offline.它有效,但您的 web 应用程序很可能会离线。 Make sure you're with always on enabled:确保您始终启用:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM