Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Azure function multiple timer trigger

We have created an azure function which is set as timer triggered . We want to schedule invoke the same func012.tion in different time intervals. i.e

1) Every Week Friday with certain set of input parameters 2) Every Month Last day with certain set of input parameters

Thanks

like image 525
user3527063 Avatar asked Jan 17 '18 02:01

user3527063


2 Answers

The timer trigger can only take a single cron schedule.
Do this as a union of schedules. Have multiple timer triggers - each with a part of the schedule (Friday vs. Monday) and then each can call to a common function passing the respective parameters.

like image 148
Mike S Avatar answered Sep 26 '22 23:09

Mike S


Here is a sample

    public async Task FunctionLogicOnTimer(string parameter)
    {
       // ...
       // ...
       
    }

    [FunctionName(nameof(MyFunc1))]
    public async Task MyFunc1(
        [TimerTrigger("%MyTimerIntervalFromSettings1%")] TimerInfo timer, ILogger log)
    {
       // ...
       // ...
       FunctionLogicOnTimer("I am triggered from MyFunc1");
    }
    
    [FunctionName(nameof(MyFunc2))]
    public async Task MyFunc2(
        [TimerTrigger("%MyTimerIntervalFromSettings2%")] TimerInfo timer ILogger log)
    {
       // ...
       // ...
       FunctionLogicOnTimer("I am triggered from MyFunc2");

    }
like image 28
Athadu Avatar answered Sep 26 '22 23:09

Athadu