Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Using aspnet 6.0.4 runtime, precedence of appsettings.json Urls
and ASPNETCORE_URLS
seems to be different compared to previous versions. Specifying ASPNETCORE_URLS
environment variable does not override the url provided in appsettings.json Urls
property. Before 6.0.4, ASPNETCORE_URLS
would have been used over Urls
in appsettings.json .
I would assume that the order that these settings are overriden in is the same as for regular settings: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0#default-configuration
Based on those, environment variables are applied after appsettings.
I am guessing this is related to dotnet/aspnetcore#39836 which meant to fix in-code overriding of any configuration value. Also, while that issue is tagged with 6.0.3, based on comment dotnet/aspnetcore#40614 (comment) it looks like it was shipped as part of 6.0.4, which is a bit confusing.
Expected Behavior
ASPNETCORE_URLS
is used instead of appsettings.json Urls
.
Steps To Reproduce
- Create new project
dotnet new webapi
- Modify
appsettings.json
by adding"Urls": "http://*:5300/"
- Set env var
export ASPNETCORE_URLS="http://*:5200/"
dotnet run
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://[::]:5300
@Rick-Anderson EDIT following lines
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 0eb4d762-3910-2c57-8741-3306c15537b6
- Version Independent ID: ba2254a0-ea8e-9b28-e94b-edd0fc58c043
- Content: Configuration in ASP.NET Core
- Content Source: aspnetcore/fundamentals/configuration/index.md
- Product: aspnet-core
- Technology: aspnetcore-fundamentals
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande