ASPNET Core: Access to Azure app settings that were secret

I have an ASPNET Core site that, working on my development machine, uses the new local secret manager to store passwords for several initial users. I get access to the secret store through IConfigurationRoot.GetSection ("username").

Here's how IConfigurationRoot is created in Startup.cs:

    var builder = new ConfigurationBuilder()
        .SetBasePath(env.ContentRootPath)
        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

    if (env.IsDevelopment())
    {
        // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
        builder.AddUserSecrets();
    }

    builder.AddEnvironmentVariables();
    Configuration = builder.Build();

This final line is the IConfigurationRoot property.

. , Azure, . Azure , . , , , , . , , , , - .

, Azure:

env vars

, .

?

+4
1

, Secret Manager . :

Secret Manager . . JSON .

, JSON . :

%APPDATA%\microsoft\UserSecrets\<userSecretsId>\secrets.json

, Azure, .

ASP.NET Core User Secrets , . Azure Azure App Services , Secret Manager . , .

secrets.json, :

{
  "AppKeys": {
    "mark": "ABCDEF",
    "connel": "abcdef"
  }
}

Azure Web App :

- ASP.NET Azure App Services ASP.NET Core.

+3

Source: https://habr.com/ru/post/1655409/


All Articles