1

I have created an azure function and is triggered by timer on specific schedule. I need this timer schedule configurable hence I would add this trigger schedule to azure function configuration settings using %TimerSchedule%.

public static void Run([TimerTrigger("%TimerSchedule%")]TimerInfo myTimer, ILogger log)
{

   // Function Code here

}

Is there a way to have some default schedule if I do not add this configuration setting?

Thank you!

1 Answer 1

2

Add a second TimerTrigger function with whatever default schedule you want. At the beginning of that function check the existence of %TimerSchedule% and if it exists then exit.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks! That's a good idea. But it will have one extra function execution. Is there any setting which can avoid this?
I don't believe so, but what is the concern of one extra function execution? It is so lightweight that it is essentially free, both from a cost and resource perspective.
That's not much of a problem. I was just checking if there is any option to avoid extra execution. Because the extra number of executions will depend on what the schedule is, like if the default schedule is to run every 3 minute, then it will run lot of times and I am planning to have 3-4 such timer triggered functions.
I suppose it depends on how vital it is that you have a default schedule that runs so frequently. One example is that you could have your default timer at something less frequent (ie. once per 60 minutes) and have it trigger an alert/notification if the %TimerSchedule% isn't set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.