Azure Functions logo

I've been using Azure Functions quite a bit. Indeed I've been recently speaking about them and the new support for .NET 5 and soon .NET 6!

Today I wanted to debug an Azure Function application, but I didn't want all of the functions in the application to run (as some of them access resources that I don't have locally). I discovered that you can add a functions property to your host.json file to list the specific functions that should run.

eg.

{
  "version": "2.0",
  "functions": [
    "function1",
    "function2"
  ]
}

But I really would prefer not to edit host.json as that file is under source control and I'd then need to remember to not commit those changes. I'd much prefer not to have to remember too many things!

There's a section in the documentation that describes how you can also set these values in your local.settings.json (which isn't usually under source control). But the examples given are for simple boolean properties. How do you enter the array value?

To find out, I temporarily set the values in host.json and used the IConfigurationRoot.GetDebugView() extension method to dump out all the configuration to see how they were represented.

Here's the answer:

{
    "Values": {
        "AzureFunctionsJobHost__functions__0": "function1",
        "AzureFunctionsJobHost__functions__1": "function2"
    }
}

The __0 and __1 represent each element in the array. With that in place when I run the Azure Function locally, only function and function2 will run. All others will be ignored. Just add additional properties (incrementing the number) to enable more functions.