2017-07-06 57 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,如果可能的話,你可以使用它。