I have following function.json for my Azure function whose schedule is set to run at 9.30 daily. What I want is to dynamically set the schedule
attribute of this json. This scenario arises when a client who is using my application enters date, on that date-scheduler should run.
{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 30 9 * * *" //Want to set dynamically
}
],
"disabled": false
}
Is this possible?
(Also note, I don't want to use Azure Scheduler due to budgeting reasons)
You could modify your function.json to fetch the cron expression from app settings.
"schedule": "%TriggerSchedule%"
Define TriggerSchedule in your appsettings. You could modify your appsettings dynamically and the function trigger would align to it.
Use Kudu API to change function.json https://github.com/projectkudu/kudu/wiki/REST-API
PUT https://{functionAppName}.scm.azurewebsites.net/api/vfs/{pathToFunction.json}, Headers: If-Match: "*", Body: new function.json content
Then send request to apply changes
POST https://{functionAppName}.scm.azurewebsites.net/api/functions/synctriggers
Or you can use Queue Trigger with "initialVisibilityDelay" messages. In this case you need to write your own code to implement a scheduler.