2
votes


there some tutorials that will show you how use Azure Timer here and here (in second one you should see limitation too)
but I need to trigger it every 90 seconds (one minute and 30 seconds).
I used these ways but seems not work:

*/30 */1 * * * * //will trigger every 30 seconds
*/90 * * * * * //will trigger every 60 seconds
30 * * * * * //will trigger each minute start at second 30

then How I can trigger it each 90 seconds?

2

2 Answers

1
votes

You would probably need to create two functions with same body, but different cron expressions:

0 0/3 * * * *  // 00:00 03:00 06:00...
30 1/3 * * * * // 01:30 04:30 07:30...

Each of those function will run every 3 minutes, with 90 seconds shift in between. It probably makes sense to reuse bodies by extracting it into a helper function, and then call it from both functions.

Another option is to create a single function that fires every 30 seconds, do the check if current time is proper multiple of 90 seconds, and return immediately otherwise.

0
votes

This is impossible using CRON (as Mikhail mentioned). However, it is highly not recommended to duplicate logic between components (different Functions in this case). It is actually the Function's parallel of a known bad-smell. Generally, for any domain, this isn't the ideal solution (I guess the reason is clear).

I would suggest one Function that holds all of the logic, which will be triggered by other Functions, which will hold minimum logic that is independent of the actual program logic. You can choose whatever suits you best, this can be either via HTTP triggers, Queues or others. Then, 2 (or any number in fact) Functions will trigger this Function using its trigger.

For example, you can create one Function with an HTTP trigger, that holds all of the logic. Then, create 2 Functions, each triggered using a different CRON expression. both will just call trigger the 'logical' function using an HTTP call.

For your specific need of 90 seconds, you can use these CRON expressions that were already suggested (one per 'trigger' Function)

0 0/3 * * * * 
30 1/3 * * * *