简体   繁体   中英

Azure Webjob TimerTrigger not working

So im trying to use the Timer Trigger in the Azure WebJobs SDK but it dosent appear to be triggering.

This is my Main method

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

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

And this is my method

[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")
}

It works fine if I invoke it manually so there's nothing wrong with the code in the method. I've also tried to use other times, eg 00:01:00 .
I also have another method that runs off a queue which invokes fine. Any idea what I'm doing wrong here?

You need to remove the [NoAutomaticTrigger] attribute.

If you decorate a function with this attribute, the JobHost will not index your function to be triggered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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