Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Provide a way of reading from the Secrets config file #158

Closed
@rustd

Description

@rustd

Project Templates will create a file to store secrets for the app
File will be created in the following folder
 Windows - AppData/Roaming/Microsoft/AspNetUserSecrets/UserSecretsId/config.secrets.json
Project.json will have the following: "userSecretsId": "aspnet5-WebApplication108-GUID",The value is the same logic we use to specify database name in config.json
Template code to read config will be as follows

public Startup(IHostingEnvironment env, IApplicationEnvironment app)
        {
            // Setup configuration sources.
            Configuration = new Configuration()
                .AddJsonFile("config.json");

            if (env.EnvironmentName =="Development" )
            {
                 Configuration.AddUserSecrets();
            }
            else
            {
                Configuration.AddJsonFile("config." + env.EnvironmentName + ".json", true)
            }
             Configuration.AddEnvironmentVariables();
        }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions