1
votes

I am trying to run the Azure webjob with trigger but my timerjob method is not triggering. I am getting below message.

No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

I am using config.UseTimers() but still showing the message. Not sure what was wrong with below code

    static void Main()
    {
        JobHostConfiguration config = new JobHostConfiguration();
        config.UseTimers();

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


    public static void TimerTrig([TimerTrigger("0 */1 * * * *", RunOnStartup = true)] TimerInfo timer)
    {
        Console.WriteLine("Triggered");
    }

I am using Microsoft.Azure.WebJobs and Microsoft.Azure.WebJobs.Host v2.2.0;

1

1 Answers

4
votes

According to your description, it seems that there is no Function.cs file in your project. You could add a Functions.cs file in your project and add your TimeTrig function in it.

We also could create the WebJob with Webjob template with VS. You could refer to the following detail steps.

1.Create a Webjob with webjob template.

enter image description here

2.Install Microsoft.Azure.WebJobs.Extensions

enter image description here

3.Add the following code in the programm.cs

 var config = new JobHostConfiguration();
 config.UseTimers(); //add this code.
 if (config.IsDevelopment)
 {
     config.UseDevelopmentSettings();
 }

  var host = new JobHost(config);
  // The following code ensures that the WebJob will be running continuously
  host.RunAndBlock();

4.In the Functions.cs File add the time triger code.

public static void TimerTrig([TimerTrigger("0 */1 * * * *", RunOnStartup = true)] TimerInfo timer)
    {
        Console.WriteLine("Triggered");
    }

enter image description here

Note: Please set the AzureWebJobsDashboard and AzureWebJobsStorage connection strings in app.config for this WebJob to run:

enter image description here