![](/img/trans.png)
[英]Can we use self-signed certification for our azure function which run on timer schedule/trigger
[英]How to set multiple schedule in azure timer function?
我有一個工作示例 azure 計時器 function,但是關於在多個時間表中設置它,我不確定是否正確設置,因為我無法立即測試它,因為它是預定的時間間隔。
我的目標是,每天早上 8:00 和晚上 8:00 顯示context.log
。
注意:我下面的代碼實際上不起作用,因為參數
hour
不接受數組(僅用於演示目的)
這是我的代碼:
export const TimerTrigger1 = TypedAzFunc.createFunctionBuilder(__dirname)
.with(
TimerTriggerPlugin.init({
schedule: {
crontab: {
second: 0,
minute: { interval: 1 },
hour: [{ interval: 8 }, { interval: 20 }],
day: '*',
month: '*',
dayOfWeek: '*',
},
},
})
)
.build(async (context, timer) => {
var timeStamp = new Date().toISOString()
if (timer.isPastDue) {
context.log('timer has already triggered')
}
context.log('timer has triggered', timeStamp)
})
export const run = TimerTrigger1.run
您可以通過在hour
屬性中傳遞一個數組來實現這一點。
TimerTriggerPlugin.init({
schedule: {
crontab: {
second: 0,
minute: 0,
hour: [8, 20],
day: '*',
month: '*',
dayOfWeek: '*',
},
},
})
這將產生一個時間表,例如:
如果今天是 2022 年 2 月 18 日早上 7:00
02/18/2022 08:00:00Z
02/18/2022 20:00:00Z
02/18/2022 08:00:00Z
02/18/2022 20:00:00Z
02/18/2022 08:00:00Z
您可以通過設置 2 個計時器來解決此問題,一個用於上午 8 點,一個用於晚上 8 點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.