Toxicable
Toxicable

Reputation: 1709

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?

Upvotes: 3

Views: 2593

Answers (1)

Thomas
Thomas

Reputation: 29522

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.

Upvotes: 1

Related Questions