Cron 表达式在 Azure 中不起作用

Cron expression doesn't work in Azure

我有一个天蓝色的网络作业,我正尝试使用 Cron 作业表达式每 2 小时 运行。我将作业配置为 OnDemand,并且我相信我已正确设置 Cron 表达式。但是,它永远不会启动。它已经在那里 2 天了。

这里是工作的快速 运行-down:

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 * * *" }

我也试过这个:

Settings.job

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

这是我在 Azure 中的作业的屏幕截图。如您所见,我以相同的方式(使用不同的 Cron 表达式)设置了其他工作,这些工作 运行ning 都很好。其他那些设置为每天 运行,而这项工作每天 运行 多次。

我在这里遗漏了什么吗? Azure 是否不允许作业 运行ning 每天不止一次(他们现在有内置的调度程序,需要额外付费)?

我认为您的 cron 表达式不正确。试试这个

"0 0 */2 * * *"

这是 cron 表达式的 link 到 Azure 文档。

希望对您有所帮助。