New console template – use user secret

  1. dotnet user-secrets init
  2. set a secret: dotnet user-secrets set “API_KEY” “test123”
  3. use UserSecretsId (from .csproj file) in AddUserSecrets()

IConfiguration configuration = new ConfigurationBuilder()
    .AddUserSecrets("d9a5cd4e-7c74-46da-a5d5-7321a7d4ae95")
    .Build();

var key = configuration["API_KEY"];

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: