2017-07-06 106 views
0

我已经发布了一个控制台应用程序作为连续运行的Web作业,使用Quartz来管理调度。石英失败的Azure Web作业

当我在本地运行文件时,Quartz工作正常。

当我将该文件作为Web作业运行时,我可以看到它按计划运行,并执行应有的操作。

然而,当我看网上作业日志,我看到象这样的错误:

[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. 

我看到就在这里等,类似的问题,但通常这涉及对集会的不匹配问题的人本地机器。

如何检查此错误是否至关重要,以及如何解决?

对此提出建议?

回答

0

我使用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!"); 
      } 
     } 

    } 
} 

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日志

enter image description here

无法加载文件或程序集“石英,版本= 2.5.0.0,文化=中性公钥= f6b8c98a402cc8a4'或其依赖项之一。该系统找不到指定的文件。

请使用the Kudu Console来访问你的网站的文件夹,并确保石英和它的依赖文件是否有(d:\家\网站\ wwwroot的\ app_data文件\ \工作持续{}工作名)。您可以尝试删除并重新部署您的作业到Azure网络应用程序。

enter image description here

此外,Azure WebJob itself can be triggered on a schedule,如果可能的话,你可以使用它。