2

I have a web job that needs to run every day at 1am. My settings.job is configured like this:

{
    "schedule": "0 0 1 * * *",
    "is_singleton":  true 
}

I have function declared in the Functions.cs

   namespace Dsc.Dmp.SddUpgrade.WebJob
{
    using System;
    using System.IO;

    using Microsoft.Azure.WebJobs;

    public class Functions
    {
        public static void TriggerProcess(TextWriter log)
        {
            log.Write($"C# Timer trigger function executed at: {DateTime.Now}");
        }
    }
}

I am getting the following logs:

[09/28/2017 12:02:05 > 9957a4: SYS INFO] Status changed to Running
[09/28/2017 12:02:07 > 9957a4: INFO] 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.).

As I read the documentation, some people are using a function signature like this:

public static void TriggerProcess([TimerTrigger("0 0 1 * * *")] TimerInfo timerInfo, TextWriter log)

However, this does not seem logic to me, because a have already configured my web job to by scheduled in the settings.job.

What am I missing here?

Identity
  • 1,553
  • 1
  • 22
  • 44

3 Answers3

3

If you use a settings.job file to schedule your WebJob, your logic should go in the Program.cs's Main function. You can ignore the Functions.cs file if you go this route. This is great for migrating a console app into a WebJob and scheduling it.

The TimerTrigger is a WebJob extension. It's useful because it's possible to have multiple methods in Functions.cs, each with a separate TimerTrigger that executes on a different schedule. To use these, your WebJob needs to be continuous.

Rob Reagan
  • 7,313
  • 3
  • 20
  • 49
2

You need to put your logic in Program.cs.

The runtime will run your WebJob by executing the executable, running the Main method in Program.cs.

juunas
  • 54,244
  • 13
  • 113
  • 149
0

You seem to be missing the [FunctionName("TriggerProcess")] attribute in the function definition, that´s why you´re getting the "job not found" error.

fermin.saez
  • 164
  • 2
  • 5