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 the 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.
3
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>
}