1
votes

I have a web job in azure that I am trying to run every 2 hours using a Cron job expression. I have the job configured as OnDemand, and I believe I have the Cron expression set up correctly. However, it NEVER gets kicked off. It's been out there for 2 days.

Here is a quick run-down of the job:

Program.cs

namespace ScheduledTrigger
{
    class Program
    {
        static void Main()
        {
            var config = new JobHostConfiguration();
            if (config.IsDevelopment)
            {
                config.UseDevelopmentSettings();
            }
            var host = new JobHost(config);
            host.Call(typeof(Functions).GetMethod("ManualTrigger"), new { value = 20 });
        }
    }
}

Functions.cs

    [NoAutomaticTrigger]
    public static void ManualTrigger()
    {
        var model = new ScheduledTriggerModel();
        ///more stuff here...
    }

webjob-publish-settings.json

{
  "$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
  "webJobName": "ScheduledTrigger",
  "runMode": "OnDemand"
}

Settings.job

{ "schedule": "0 2,4,6,8,10,12,14,16,18,20,22 * * *" }

I have also tried this:

Settings.job

{ "schedule": "0 */2 * * *" }

Here is a screenshot of my jobs in Azure. As you can see, I have other jobs set up the same way (with different Cron expressions) that have been running just fine. Those others are set to run every day, where as this job is running multiple times a day.

enter image description here

Is there something I'm missing here? Does Azure disallow jobs running more than once per day (they now have their built in scheduler, which comes at a premium)?

1

1 Answers

2
votes

I think your cron expression is incorrect. Try this

"0 0 */2 * * *"

Here is the link to Azure documentation for cron expressions.

Hope it helps.