Azure Web作业与Quartz失败
我已经发布了一个控制台应用程序作为一个持续运行的web作业,使用Quartz来管理调度 当我在本地运行该文件时,Quartz工作正常 当我将文件作为web作业运行时,我可以看到它按计划运行,并执行它应该执行的操作 但是,当我查看web作业日志时,会看到如下错误:Azure Web作业与Quartz失败,azure,azure-webjobs,quartz.net,Azure,Azure Webjobs,Quartz.net,我已经发布了一个控制台应用程序作为一个持续运行的web作业,使用Quartz来管理调度 当我在本地运行该文件时,Quartz工作正常 当我将文件作为web作业运行时,我可以看到它按计划运行,并执行它应该执行的操作 但是,当我查看web作业日志时,会看到如下错误: [07/06/2017 09:48:59 > dd118a: ERR ] Unhandled Exception: System.IO.FileNotFoundException: Could not load file or a
[07/06/2017 09:48:59 > dd118a: ERR ] Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Quartz, Version=2.5.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4' or one of its dependencies. The system cannot find the file specified.
我在这里看到了其他类似的问题,但通常这涉及到人们在本地机器上存在程序集不匹配问题
如何检查此错误是否严重,以及如何修复它
建议?我使用Quartz.NET库(v2.5.0)对以下示例代码进行了测试,它在本地和部署为WebJobs上都可以正常工作
using Quartz;
using Quartz.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace QuartzTest
{
class Program
{
static void Main(string[] args)
{
try
{
Common.Logging.LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter { Level = Common.Logging.LogLevel.Info };
// Grab the Scheduler instance from the Factory
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
// and start it off
scheduler.Start();
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("job1", "group1")
.Build();
// Trigger the job to run now, and then repeat every 10 seconds
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(10)
.RepeatForever())
.Build();
// Tell quartz to schedule the job using our trigger
scheduler.ScheduleJob(job, trigger);
// some sleep to show what's happening
Thread.Sleep(TimeSpan.FromSeconds(60));
// and last shut down the scheduler when you are ready to close your program
scheduler.Shutdown();
}
catch (SchedulerException se)
{
Console.WriteLine(se);
}
//Console.WriteLine("Press any key to close the application");
//Console.ReadKey();
}
public class HelloJob : IJob
{
public void Execute(IJobExecutionContext context)
{
Console.WriteLine("Greetings from HelloJob!");
}
}
}
}
使用石英;
使用Quartz.Impl;
使用制度;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用系统线程;
使用System.Threading.Tasks;
名称空间QuartzTest
{
班级计划
{
静态void Main(字符串[]参数)
{
尝试
{
Common.Logging.LogManager.Adapter=new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter{Level=Common.Logging.LogLevel.Info};
//从工厂获取调度程序实例
isScheduler scheduler=StdSchedulerFactory.GetDefaultScheduler();
//然后开始
scheduler.Start();
//定义作业并将其绑定到HelloJob类
IJobDetail job=JobBuilder.Create()
.WithIdentity(“工作1”、“组1”)
.Build();
//立即触发作业运行,然后每10秒重复一次
ITrigger trigger=TriggerBuilder.Create()
.WithIdentity(“触发器1”、“组1”)
.StartNow()
.使用SimpleSchedule(x=>x
.间隔秒(10)
.RepeatForever())
.Build();
//告诉quartz使用触发器安排作业
ScheduleJob(作业,触发器);
//一些睡眠来显示发生了什么
线程睡眠(时间跨度从秒(60));
//最后在准备关闭程序时关闭计划程序
scheduler.Shutdown();
}
捕获(调度)
{
控制台写入线(se);
}
//Console.WriteLine(“按任意键关闭应用程序”);
//Console.ReadKey();
}
公共类HelloJob:IJob
{
public void Execute(IJobExecutionContext上下文)
{
Console.WriteLine(“来自HelloJob的问候!”);
}
}
}
}
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Common.Logging" version="3.3.1" targetFramework="net452" />
<package id="Common.Logging.Core" version="3.3.1" targetFramework="net452" />
<package id="Microsoft.Web.WebJobs.Publish" version="1.0.12" targetFramework="net452" />
<package id="Quartz" version="2.5.0" targetFramework="net452" />
</packages>
WebJobs日志
无法加载文件或程序集“Quartz,版本=2.5.0.0,区域性=中性,PublicKeyToken=f6b8c98a402cc8a4”或其依赖项之一。系统找不到指定的文件
请使用访问站点的文件夹,并确保Quartz及其依赖项文件存在(D:\home\site\wwwroot\app\u data\jobs\continuous{jobname})。您可以尝试删除作业并将其重新部署到Azure web应用程序
此外,如果可能的话,你可以使用它