繁体   English   中英

Azure Webjob TimerTrigger 不起作用

[英]Azure Webjob TimerTrigger not working

所以我试图在 Azure WebJobs SDK 中使用计时器触发器,但它似乎没有触发。

这是我的主要方法

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
我还有另一种方法可以运行在调用正常的队列之外。 知道我在这里做错了什么吗?

您需要删除[NoAutomaticTrigger]属性。

如果您使用此属性装饰函数, JobHost将不会索引您要触发的函数。

暂无
暂无

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

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