Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 949
Toxicable Avatar asked Jan 31 '26 11:01

Toxicable


1 Answers

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.

like image 198
Thomas Avatar answered Feb 02 '26 23:02

Thomas