-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Describe the bug
I've been experimenting with the new minimal hosting APIs using WebApplication in a small .NET 5 sample app (martincostello/SignInWithAppleSample#69), and compared to .NET 5 the configuration associated with the WebApplicationBuilder returned by WebApplication.CreateBuilder(string[]) does not appear to include user secrets, which is different compared to the experience of using the HostBuilder with .NET 5.
In this use case the user secrets are being used to bootstrap the configuration of the application locally to determine whether the settings required to use Azure Key Vault are present in the user secrets or not. It's slightly chicken-and-egg using the configuration to build the configuration, but the scenario works in the existing .NET 5 hosting with no specific thought required, it Just Works™️.
I would expect User Secrets to similarly be automatically available in the default builder during local development, or if they are, I would expect them to be available earlier than they are at the moment.
.NET 5.0.6
In .NET 5, the user secrets are automatically made available when a call to ConfigureAppConfiguration() is made to add further configuration sources (code). In the screenshot below it is the third JSON source:
.NET 6 preview 4
With .NET 6 preview 4 users secrets are not available in the configuration sources as shown below. To make it available, the application has to explicitly add it (code).
To Reproduce
Compare the behaviour of e63d731 (.NET 6 preview 4) and 61e78f7 (.NET 5.0.6) when bootstrapping the configuration to add Azure Key Vault (see code links above).
Further technical details
- ASP.NET Core
6.0.100-preview.4.21255.9 - Visual Studio 2019 16.11.0 Preview 1.0

