2
votes

I have an Azure WebJob which I am publishing from visual studio 2017 to a Standard S1 App Service, the WebJob should be Triggered by CRON but always publishes as Continuous and I cannot figure out what I have done wrong (two other WebJobs publish fine)

I have the App Service set to 'Always On' in application settings enter image description here

I have a settings.job file in the root with my schedule

{
     "schedule": "0 3 5 * * 1-5"
}

enter image description here

My Program class

namespace EventPushUpdater
{
    using Microsoft.Azure.WebJobs;
    using MBL.AzureKeyVaultHelpers;

    internal class Program
    {
        private static void Main()
        {
            Properties.Settings s = Properties.Settings.Default;

            IKeyVault kv = new KeyVaultHelper(s.ClientId, s.ClientKey, s.KeyVaultRoot);

            var config = new JobHostConfiguration();
            config.DashboardConnectionString = kv.GetSecretValue(s.DashboardConnectionString);
            config.StorageConnectionString = kv.GetSecretValue(s.DashboardConnectionString);            
            var host = new JobHost(config);

            host.Call(typeof(Functions).GetMethod("PushEvents"), new { keyVault = kv });
        }
    }

}

And the function being called

public class Functions
{
    [NoAutomaticTrigger]
    public static void PushEvents(IKeyVault keyVault)
    {
         // do stuff
    }
}
3

3 Answers

5
votes

The first time you chose 'Publish as a WebJob', it asks you if you want Continuous or On Demand (which includes scheduled):

WebJob publish

If you picked the wrong choice, simply delete webjob-publish-settings.json under Properties, and try again.

As an aside, your code is overly complex as you're needlessly using WebJobs SDK. Instead, your code can simply be:

    static void Main()
    {
        // Do Stuff
    }
5
votes

You can switch between 'Continuous' and 'Triggered' modes by editing the webjob-publish-settings.json file that is found within the Properties folder of your WebJob project.

webjob-publish-settings.json

In this json file you can set "runMode:" to either Continuous or OnDemand (triggered) :

Continuous

Continuous

OnDemand

Triggered

1
votes

Have you set { "is_singleton": true } in your settings.job? If so you cannot run more than one instance of your WebJob. If you publish and run your WebJob to the Azure cloud you cannot never run it locally unless you use a different storage account.

Azure Webjob timer trigger does not fire