I want to limit which functions get executed when running my Azure Functions project locally. I would usually do this by adding a functions
array to my host.json file, however upon reading this article I figured it would be nice to do it in my launchsettings.json instead.
If I override other host.json properties by setting values in the environmentVariables
section of my launchsettings.json file (eg, "AzureFunctionsJobHost__extensions__queues__batchSize": "1"
) they are loaded properly, however if I do the following: "AzureFunctionsJobHost__functions": "myFunc1, myFunc2"
I get a blue line in the console saying [2023-01-05T19:18:51.150Z] A function allow list has been specified, excluding all but the following functions: ["myFunc1", "myFunc2"]
followed by a yellow one which states [2023-01-05T19:18:51.219Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
.
If I place the following in my host.json file, however, I get the desired behavior: {"version": "2.0", "functions": [ "myFunc1", "myFunc2" ]}
.
If I misstype a function name in host.json in purpose I get the same "no job functions found" result as I see when trying to set them in appSettings, so I'm guessing this could be a matter of how the values are passed into that env. variable VS how it must be defined in host.json, however I've found no combination (with/without single quotes, double quotes, square brackets..) which produces the right behavior.
I'm using .Net 6 with Azure Functions v4.