2016-04-23 90 views
2

所以即時嘗試使用Azure WebJobs SDK中的計時器觸發器,但它的劑量似乎是觸發。Azure Webjob TimerTrigger不起作用

這是我的主要方法

var config = new JobHostConfiguration(); 
config.UseTimers(); 

JobHost host = new JobHost(config); 
host.RunAndBlock(); 

這是我的方法

[NoAutomaticTrigger] 
public static void GetNextMaint([TimerTrigger("00:00:01", RunOnStartup = true)] TimerInfo info, TextWriter log) 
{ 
    log.WriteLine("Getting info from url") 
    var info = WebsiteHelper.GetInfoFromWebsite(..website...); 
    var db = new ApplicationDbContext(); 
    db.Info.Add(new Info{ text = info}); 
    db.SaveChanges(); 
    log.WriteLine("Complete, shutting down") 
} 

如果我手動調用它,所以沒有什麼錯在方法中的代碼,它工作正常。我也嘗試過使用其他時間,例如00:01:00
我也有另一種方法,運行罰款調用的隊列。任何想法我在這裏做錯了嗎?

+1

可能會有助於http://stackoverflow.com/questions/34665763/azure-webjobs-timertrigger-not-triggering – Nitin

+0

@Nitin謝謝,我不知道有關開發設置。仍然是同樣的問題,但它應該證明有用 – Toxicable

回答

1

您需要刪除[NoAutomaticTrigger]屬性。

如果你用這個屬性裝飾一個函數,JobHost將不會索引你的函數被觸發。

+0

哦......這是有道理的感謝。我剛纔在那裏提到'JobHost'沒有看到我的函數 – Toxicable