【问题标题】:Schedule Azure Function according to weekday根据工作日安排 Azure Function
【发布时间】:2021-10-18 06:21:54
【问题描述】:

我想将我的 Azure 函数安排为: 11:00 AM for Monday to Friday , 2:30 AM for Saturday & Sunday

如何为此编写 cron 表达式?

请帮忙。

【问题讨论】:

标签: c# azure .net-core azure-devops azure-functions


【解决方案1】:

不幸的是,您需要有两个 azure 函数

public static void RunMonFriday([TimerTrigger("0 0 11 * * 1-5")]TimerInfo 
myTimer, ILogger log) { 
   // Call method to job
}
public static void RunSatSun([TimerTrigger("0 30 2 * * 6-7")]TimerInfo m
yTimer, ILogger log){
   // Call method to job
}

【讨论】:

    【解决方案2】:

    您可以尝试在管道中使用 Invoke Azure function 和环境。

    这是一个例子:

    在 Azure devops 中配置 schedule in your pipeline。 这是一个例子:

        # YAML file in the main branch
    schedules:
    - cron: "0 0 * * *"
      displayName: Daily midnight build
      branches:
        include:
        - master
    - cron: "0 12 * * 0"
      displayName: Weekly Sunday build
      branches:
        include:
        - master
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      • 2013-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多