I have Azure function with timer trigger.
public static void Run([TimerTrigger("0 */15 * * * *"), Disable("True")]TimerInfo myTimer, TraceWriter log)
Here the Disable("true")
is not working. it generates the function.json
as
"disabled": "True",
which is not correct. It should be "disabled": True,
Disable only accepts string value.
Is there any way to change this? or any other way to disable function?
Have you tried modifying the host.json inside your solution? It has the following properties for you to specify which functions to load on runtime.
Note that if you have multiple Function App projects in your solution, you will also need to make to change to their corresponding host.json (i.e. each project has their own host.json)
Documentation: https://github.com/Azure/azure-webjobs-sdk-script/wiki/host.json
The string typed value - "disabled": "true" also could disable the function. Please see the test result as following.
Here is my function definition.
Here is the published function on Azure portal.
Functions 2.x can be disabled individually via
local.settings.json
in the following mannerRef: https://docs.microsoft.com/en-us/azure/azure-functions/disable-function#functions-2x---all-languages
Disable properties default values is
true
.Use
Disable()
instead ofDisable("true")
.So the code will look like
public static void Run([TimerTrigger("0 */15 * * * *"), Disable()]TimerInfo myTimer, TraceWriter log)
.If you want to enable the function use
Disable("False")
.