There are three ways to implement it.
- Disable functions:
One is modifying the function.json:
"bindings": [
...
],
"disabled": "IS_DISABLED"
Another is use Disable
attribute to prevent a function from being triggered.
[Disable]
[FunctionName("Function")]
[NoAutomaticTrigger]
public static void Function(string input, TraceWriter log)
{
}
With Azure Functions Core Tools, only for version 1.x
func run <functionName>
host.json:
{
"functions": [ "QueueProcessor", "GitHubWebHook" ]
}
Update:
4: as jtlz2 answered, this way is for disable functions locally with local.settings.json
.
{
"Values": {
"AzureWebJobs.MyFunctionName.Disabled": true
"AzureWebJobs.MyFunctionName2.Disabled": false
}
}
**Update:**as @ahmelsayed explains something about there are many options to call only one function, so i update it here.
"Disabled" is meant to be used to dynamically turn a function on or off. The runtime will still load the function, and will display any errors or issues with the function (incorrect settings etc), but will not execute the code. There are many ways to enable/disable a function because some want to keep that in source control and for some it's a devops operation
The functions
array in host.json is something I wasn't initially aware of. It was added to the runtime for the convenience of the runtime developers who have a large folder of samples that they wanted to be able to load only a subset of. This completely ignores functions that are not listed. They won't be indexed or loaded in anyway.