创建Webjob后更改CRON

时间:2019-05-23 07:35:32

标签: azure webjob

一旦作业创建为在8:00 AM运行,我能否在Azure门户中的settings.job中而不是将CRON更改为1:00 AM?如果是这样,该怎么做?

1 个答案:

答案 0 :(得分:0)

Timer触发器Webjob现在支持NameResolver来绑定CustomCustom表达式,有关更多详细信息,请参考此文档:Custom binding expressions

如果需要一些示例,请参考下面的代码或此doc

 namespace WebJob.Schedule
{
  class Program
  {
    static void Main(string[] args)
    {
      JobHostConfiguration config = new JobHostConfiguration();
      config.NameResolver = new MagicResolver();
      config.UseTimers();

      JobHost host = new JobHost(config);
      host.RunAndBlock();
    }

    private class MagicResolver : INameResolver
    {
      public string Resolve(string name)
      {
        string value = ConfigurationManager.AppSettings["MagicSchedule"];              
      }
    }
  }

  public class Magic
  {
    public static void ScheduleTimeTrigger([TimerTrigger("%MagicSchedule%")] TimerInfo timer)
    {
      // Your magic web job task here
    }
  }
}