dotnet new -o configbuilder
cd configbuilder
dotnet user-secrets init
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
dotnet add package Microsoft.Extensions.Configuration.EnvironmentVariables
export MyAwesomeApp__Location=Ukraine
dotnet user-secrets set MySecret "s3cret!"
Created
August 25, 2022 13:28
-
-
Save NikiforovAll/c2c7479ba4109595ad93cbfbc13f103a to your computer and use it in GitHub Desktop.
ConfigurationBuilder Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.Configuration; | |
var configuration = new ConfigurationBuilder() | |
.AddInMemoryCollection(new Dictionary<string, string>{ ["Label"] = "Secret"}) | |
.AddEnvironmentVariables("MyAwesomeApp") | |
.AddUserSecrets<Program>() | |
.Build(); | |
Console.WriteLine(configuration.GetDebugView().Trim(':').Trim()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment