I've some azure functions that I want to disable/enable programmatically - e.g. by an http triggered function.
Is there a way to do this directly in C# code of the function? I couldn't find anything like an api for that.
Another option could be to use the app settings of the function app with a parameter like "FUNCTION1_ENABLED"
.
With this, the function would not be really disabled but I can read this value on the beginning of the function and break it, if its false. But it looks like, that the app settings only can be set on startup of a function app - and not during runtime.
The final (but at least inelegant) solution would be to share a parameter stored in the database behind all functions - that can easily be set and read by any function.
But I hope, there is a way to disable/enable functions programmatically in C# by Azure itself.
CodePudding user response:
You can stop the Function by using REST:
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/stop?api-version=2021-02-01