'How to set multiple schedule in azure timer function?
I have a working sample azure timer function, but about setting it in multiple schedule, I'm not sure if doing it correctly, because I can't test it immediately because it is scheduled hours gap.
My goal is, to display context.log every 8:00AM, and 8:00PM every day.
note: my code below actually don't work because parameter
hourdoes not accept array (for demonstration purpose only)
Here is my code:
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
Solution 1:[1]
You could solve this by having 2 timers, one for 8 am and one for 8 pm.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Shiraz Bhaiji |
