4

I have a number of function apps that run based on "Timer Triggers"

At the moment they are running every 5 minutes.

public static async Task Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log)

I want to be able to read the current timer setting and change the TimerTrigger value programmatically so that we can change it from a management portal.

Is this possible?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Trevor Daniel
  • 3,785
  • 12
  • 53
  • 89

2 Answers2

7

There is no way to this today when using the VS precompiled model. But it is interesting feedback, and I suggest opening an issue on https://github.com/Azure/azure-functions/issues.

Update: it's actually possible to achieve this using an App Setting to hold the cron. Stealing example from https://github.com/Azure/azure-webjobs-sdk-script/issues/1934:

public static void Run([TimerTrigger("%CRON_EXPRESSION%")]TimerInfo myTimer, TraceWriter log)
David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • I would like to see this supported as well: https://github.com/Azure/azure-webjobs-sdk-script/issues/2077 – Kris Oct 30 '17 at 03:41
3

If you deploy your app using an arm template and put your schedule in the function.json bindings section, instead of as an attribute, in the arm template, then you can update the schedule by just rerunning the arm template, which will do a differential update....or you can go into the management portal and edit the binding there.

Jeff
  • 35,755
  • 15
  • 108
  • 220
  • Yes, but that won't work for the scenario where you deploy from VS with precompiled functions. – David Ebbo Sep 15 '17 at 23:33
  • Precompiled functions still can use a function.json file for bindings – Jeff Sep 16 '17 at 00:05
  • The runtime will not consume it in the precompiled case. – David Ebbo Sep 16 '17 at 04:01
  • If you deploy the function.json with an entry point and script file setting it will – Jeff Sep 16 '17 at 15:39
  • Yes, but when publishing from VS, you will also see a `"configurationSource": "attributes"` in `function.json`, which causes the compiled attribute to take over the bindings. You could of course remove all that, but at that point you'll be fighting the system on every publish and wont' have a good workflow. So we do need to improve things to support this smoothly. – David Ebbo Sep 16 '17 at 17:16