AFAIK you can not create a cron expressions with different distance between each trigger.
You can solve your problem in multiple ways programmatically:
- Create a single cron expression that represents the biggest common denominator. E.g.
- in your example it would be 15 minutes
- so expression would be
0 0/15 0 ? * * *
- Make function intelligent enough to decide if it should skip or serve the trigger. E.g. a dumb approach would be:
public class CronFunction {
private void processEvent(String event) {
// process...
}
@FunctionName("cron")
public void cronFunc(
@TimerTrigger(schedule = "0 0 0/1 ? * SAT,SUN *") String event, ExecutionContext context) {
curr_day = ...;
curr_time = ...;
if ((curr_day == today and curr_time in ['09:00:00', '22:00:00', '22:15:00']) ||
(curr_day == tomorrow and curr_time in ['09:00:00'])) {
processEvent(event);
} else {
logger.debug("skipping trigger");
}
}
}
Create multiple triggers, all calling same implementation.
public class CronFunctions {
private void processEvent(String event) {
// process...
}
@FunctionName("cron1")
public void cronFunc1(
@TimerTrigger(schedule = "0 0 0/1 ? * SAT,SUN *") String event, ExecutionContext context) {
processEvent(event);
}
@FunctionName("cron2")
public void cronFunc2(
@TimerTrigger(schedule = "0 0/15 0 ? * MON,TUE,WED,THU,FRI *") String event,
ExecutionContext context) {
processEvent(event);
}
}