I have a set of Azure Functions, which are developing in Visual Studio.
There is one TimerTrigger function, which is disabled by default with DisableAttribute. This results "disabled"
attribute to be set to true
on Azure portal.
Once special condition is met, another function is triggered, which updates the TimerTrigger function.json
file with "disabled": false
. This launches the TimerTrigger.
But when the other condition is met, the function.json of TimerTrigger updated with "disabled": true
, which takes no effect, TimerTrigger still fires.
The update of function.json is performed like described here How to Enable/Disable Azure Function programmatically.
I've read through multiple issues on GitHub, still no answer. I see the following workarounds:
- Try modifying host.json file with functions list updated each time. But I couldn't find any sample of changing host.json file. Also, I assume it is not very good approach, as all functions are reloaded during such update, and in documentation there is advice use this approach only for local debugging. https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#functions.
- Bind DisableAttribute on AppSetting. But I find the process of updating
app.settings
to sophisticated. Change Azure website app settings from code. - Reconsidering architectural approach.
The main purpose of TimerTrigger - is to get enabled and start calling some server when it's down (ConnectionValidator). As soon as server is OK - disabling TimerTrigger, and continuing usual workflow.
Any ideas about this? Maybe there is some other way to workaround this?