Skip to content

[Breaking change]: Environment variables take precedence in app runtime configuration settings #50993

@elinor-fung

Description

@elinor-fung

Description

Starting with .NET 9, the priority of how app runtime configuration (https://learn.microsoft.com/dotnet/core/runtime-config/) is resolved has changed. If both an environment variable and a corresponding setting in the application's runtimeconfig.json (or project file) are provided, the environment variable takes precedence over the configuration file.

dotnet/runtime#121899

Version

.NET 9

Previous behavior

When both an environment variable and the corresponding setting in the application's runtimeconfig.json are set, the runtimeconfig.json took precedence.

New behavior

When both an environment variable and the corresponding setting in the application's runtimeconfig.json are set, the environment variable takes precedence.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

The new behaviour is more consistent with how configuration tends to work in .NET and elsewhere, with environment variables taking precedence.

Recommended action

If running in an environment with the environment variable set to a configuration value different than what is desired, either unset the environment variable or set it to the desired configuration value.

Feature area

Deployment

Affected APIs

No response


Associated WorkItem - 544017

Metadata

Metadata

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions