Since this post already has good answers, I want to share my experience here. I was trying to run the app locally by adding the cron expression in the appsettings.json
file but then when I ran the function app I always received an error as follows
The 'EmployeeTimerTrigger' function is in error:
Microsoft.Azure.WebJobs.Host: Error indexing method
'EmployeeTimerTrigger'. Microsoft.Azure.WebJobs.Host:
'%EmployeeTimerTrigger%' does not resolve to a value.
So in order to resolve that what we need to do is shift the cron expression from appsettings.json
to local.settings.json
and it worked just fine and I was able to test it locally.
Edit: Adding notes for deployment
The function app reads the timer trigger settings from the application settings of the function app itself on azure.
When you plan to deploy your function app in azure there's a small change that you need to do in the Application Settings of the function app in the Azure portal.
You can navigate to those settings by selecting the function app in azure portal -> Configuration -> Application setting
The very first setting that you need to add is the time zone in which you want the timer trigger to run here's an example of the same
Note: Please note these values are case sensitive
Now the second setting we will add here is for our timer trigger function, in this image you will see that the timer will run at 10:00 AM and 2:00 PM eastern standard time.
Why eastern standard time you ask? well, remember our first settings were for the website time zone so both settings work hand in hand.
Note: The name of the timer trigger should match the one you have in your function app, please note these values are case sensitive and should match exactly with what you have in your timer trigger function.
Once you have added these settings, don't forget to save your changes and now you are all set to deploy your function app.
I hope this answer helps in the deployment and running the timer function locally.