代码之家  ›  专栏  ›  技术社区  ›  Matt Spinks

Cron表达式在Azure中不起作用

  •  1
  • Matt Spinks  · 技术社区  · 6 年前

    OnDemand ,我相信Cron表达式设置正确。然而,它从未被启动过。已经有两天了。

    程序.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 });
            }
        }
    }
    

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

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

    我也试过:

    设置.job

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

    enter image description here

    有什么我遗漏的吗?Azure是否不允许作业每天运行一次以上(它们现在有了内置的调度程序,这是一个额外的功能)?

    1 回复  |  直到 6 年前
        1
  •  2
  •   developer9    6 年前

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

    "0 0 */2 * * *"
    

    这是链接到 Azure

    希望有帮助。