I have a function app that i run and one of the functions is as follows:
[Function("JobsTrigger")]
public void Run([TimerTrigger("1,31 * * * * *", RunOnStartup = true)] MyInfo myTimer)
{
<rest of code>
}
Now how can i put the CRON expression "1,31 * * * * *" in the local.settings.json file and when i deploy to put in the appsettings.json file ?
So in other words when the function app starts up i want to read that parameter setting from the appsettings.json file ?
You can define your CRON expression in local.settings.json
:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"YourSchedule": "1,31 * * * * *"
}
}
and then you should be able to reference it by name in your Azure Function:
[Function("JobsTrigger")]
public void Run([TimerTrigger("%YourSchedule%", RunOnStartup = true)] MyInfo myTimer)
{
// <rest of the code>
}