Search code examples
c#azure-webjobs

Azure Web Job Timer trigger not firing


I am new to azure web jobs. i am using azure extentions and core both with version 2.0.0. i am using this git repo which i understand uses beta versions of the nigets. at the moment i am running the application in debug mode in my local machine. I created a function to run every min with TimerTrigger. the code is below,

static void Main()
    {
        var config = new JobHostConfiguration();
        config.UseTimers();
        config.Tracing.ConsoleLevel = System.Diagnostics.TraceLevel.Verbose;

        if (config.IsDevelopment)
        {
            config.UseDevelopmentSettings();
        }

        var host = new JobHost();
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();
    }
   [NoAutomaticTrigger]
   public static void TimerTrig([TimerTrigger("0 * * * * *", RunOnStartup = true)] TimerInfo timer)
        {
            Console.WriteLine("Triggered");
        }

My questions are, - None of the example i have seen online uses [NoAutomaticTrigger] attribute. but if i don't use it the the job host cannot find the function itself. - the function is not firing. i have used set time in the cron notation, run start up = true, making trace console level to verbose.

what am i missing?


Solution

  • Try passing your config as a parameter to the Job Host constructor.

    var host = new JobHost(config);