Azure / Azure/azure-functions-dotnet-worker

No way to disable functions locally in isolated mode based on different environments (only using local.settings.json)

Open
#1,398 48 comments 26 reactions 0 assignees View on GitHub
enhancement pending-design
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

### Description
We are currently migrating a .NET 6 in-process function app to isolated mode, and are running into issues when trying to disable functions during local development. Our requirements are to disable certain functions in some local environment settings, but enable them for others. Thus, simply putting stuff into the `local.settings.json` is no solution for us.

With the old in-process libs, we were using `[Disable("Setting")]` Attributes on the functions we wanted disabled, and we were configuring those settings in `appsettings..json` files we added during function startup using the regular `AddJsonFile` configuration extensions. The `[Disable]` Attribute does not work any more (at least currently not, related #312 and #438). And using the `AzureWebJobs..Disabled` approach only works, when putting those settings into the `local.settings.json`. It seems that somehow, all Functions are already loaded and configured before any `HostBuilder` user code executes. That means, adding any configuration in `ConfigureHostConfiguration` or `ConfigureAppConfiguration` is too late and will not disable any functions. We are not sure if this is by design, but it seriously constraints any dynamic configuration of functions when developing locally.

### Expected behavior
We would expect to have any way to disable functions during startup with a more dynamic mechanism except the `local.settings.json`, depending on the configured environment.

### Actual behavior
There is no way to locally disable functions by configuration except `local.settings.json`, at least none we found.

### Known workarounds
We could use compiler flags and combine different environment with those compiler flags, to simply remove the affected functions from the code. But this feels extremely clunky, ugly and error-prone.

### App Details

- **Functions versions**:
Microsoft.Azure.Functions.Worker 1.10.0
Microsoft.Azure.Functions.Worker.Sdk 1.7.0
Microsoft.Azure.Functions.Extensions.Http 3.0.13
Microsoft.Azure.Functions.Extensions.Timer 4.1.0
- **Azure Functions runtime version**: v4
- **Programming language used**: C#

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the issue discussion and the Azure Functions worker startup/configuration path described in the report, including ConfigureHostConfiguration and ConfigureAppConfiguration. Done means establishing a supported way to disable functions from environment-specific startup configuration rather than only local.settings.json, with the behavior verified for isolated-mode local development.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.