I'm using the new C# assembly deployments in Azure Functions.
I want to be able to configure my timer trigger schedule differently in pre-production environments (less frequently) than in production. I'm running a script in my VSTS release to modify the function.json file in the web deploy package before deploying to my App Service.
It looks like whatever string is passed into the TimerTriggerAttribute constructor overrides the value in function.json. I've tried the second overload of the constructor to avoid compiling the schedule into the assembly but the compiler throws an error that the ScheduleType property is not supported.
Is there any supported way of configuring timer schedules differently in different environments, other than compiling different versions of the assembly?
Yes. Instead of hardcoding a cron expression, put the expression in an app setting and refer to it using % signs. For instance, if you have a setting called CRON_EXPRESSION:
public static void Run([TimerTrigger("%CRON_EXPRESSION%")]TimerInfo myTimer, TraceWriter log)
Thanks @anthonychu I know I read about using settings this way at some point but I must have forgotten.
Most helpful comment
Yes. Instead of hardcoding a cron expression, put the expression in an app setting and refer to it using
%signs. For instance, if you have a setting calledCRON_EXPRESSION: