/// <summary>
        /// Creates and configures the application configuration, where key value pair settings are stored. See
        /// http://docs.asp.net/en/latest/fundamentals/configuration.html
        /// http://weblog.west-wind.com/posts/2015/Jun/03/Strongly-typed-AppSettings-Configuration-in-ASPNET-5
        /// </summary>
        /// <param name="hostingEnvironment">The environment the application is running under. This can be Development, 
        /// Staging or Production by default.</param>
        /// <returns>A collection of key value pair settings.</returns>
        private static IConfiguration ConfigureConfiguration(IHostingEnvironment hostingEnvironment)
        {
            IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            // Add configuration from the config.json file.
            configurationBuilder.AddJsonFile("config.json");

            // Add configuration from an optional config.development.json, config.staging.json or 
            // config.production.json file, depending on the environment. These settings override the ones in the 
            // config.json file.
            configurationBuilder.AddJsonFile($"config.{hostingEnvironment.EnvironmentName}.json", optional: true);

            // This reads the configuration keys from the secret store. This allows you to store connection strings
            // and other sensitive settings, so you don't have to check them into your source control provider. See 
            // http://go.microsoft.com/fwlink/?LinkID=532709 and
            // http://docs.asp.net/en/latest/security/app-secrets.html
            configurationBuilder.AddUserSecrets();

            // Add configuration specific to the Development, Staging or Production environments. This config can 
            // be stored on the machine being deployed to or if you are using Azure, in the cloud. These settings 
            // override the ones in all of the above config files.
            // Note: To set environment variables for debugging navigate to:
            // Project Properties -> Debug Tab -> Environment Variables
            // Note: To get environment variables for the machine use the following command in PowerShell:
            // $env:[VARIABLE_NAME]
            // Note: To set environment variables for the machine use the following command in PowerShell:
            // $env:[VARIABLE_NAME]="[VARIABLE_VALUE]"
            // Note: Environment variables use a colon separator e.g. You can override the site title by creating a 
            // variable named AppSettings:SiteTitle. See 
            // http://docs.asp.net/en/latest/security/app-secrets.html
            configurationBuilder.AddEnvironmentVariables();

            return configurationBuilder.Build();
        }
示例#2
1
        public Startup(IHostingEnvironment env)
        {
            HostingEnvironment = env;

            // Set up configuration sources
            var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddEnvironmentVariables();

            if (HostingEnvironment.IsDevelopment())
            {
                builder.AddUserSecrets();
            }

            Configuration = builder.Build();
        }
示例#3
0
        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json")
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

            if (env.IsEnvironment("Development"))
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();
            }

            // this file name is ignored by gitignore
            // so you can create it and use on your local dev machine
            // remember last config source added wins if it has the same settings
            builder.AddJsonFile("appsettings.local.overrides.json", optional: true);

            // most common use of environment variables would be in azure hosting
            // since it is added last anything in env vars would trump the same setting in previous config sources
            // so no risk of messing up settings if deploying a new version to azure
            builder.AddEnvironmentVariables();
            Configuration = builder.Build();

            //env.MapPath
            appBasePath = appEnv.ApplicationBasePath;
        }
        public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            InitializeLogging(loggerFactory);
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json");

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

            // Uncomment the block of code below if you want to load secrets from KeyVault
            // It is recommended to use certs for all authentication when using KeyVault
//#if NET451
//            var config = builder.Build();
//            builder.AddKeyVaultSecrets(config["AzureAd:ClientId"],
//                config["KeyVault:Name"],
//                config["AzureAd:Asymmetric:CertificateThumbprint"],
//                Convert.ToBoolean(config["AzureAd:Asymmetric:ValidationRequired"]),
//                loggerFactory);
//#endif

            Configuration = builder.Build();
        }
示例#5
0
        public Startup(
            IHostingEnvironment env,
            IApplicationEnvironment appEnv)
        {
            _env = env;

            // Setup configuration sources.
            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                // standard config file
                .AddJsonFile("config.json")
                // environment specific config.<environment>.json file
                .AddJsonFile($"config.{env.EnvironmentName}.json", true /* override if exists */)
                // standard Windows environment variables
                .AddEnvironmentVariables();

            if (env.IsDevelopment())
            {
                // this one adds not using directive to keep it secret, only a dnx reference
                // the focus is not on Secrets but on User, so these are User specific settings
                // we can also make it available only for developers
                builder.AddUserSecrets();
            }

            Configuration = builder.Build();
        }
示例#6
0
        public Startup(IHostingEnvironment env)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("version.json")
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true)
                .AddEnvironmentVariables();

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

                // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
                builder.AddApplicationInsightsSettings(developerMode: true);
            }
            else if (env.IsStaging() || env.IsProduction())
            {
                // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
                builder.AddApplicationInsightsSettings(developerMode: false);
            }

            Configuration = builder.Build();

            Configuration["version"] = new ApplicationEnvironment().ApplicationVersion; // version in project.json
        }
示例#7
0
文件: Startup.cs 项目: lulzzz/Questy
        public Startup(IHostingEnvironment env)
        {
            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddJsonFile($"setup.json", optional: true, reloadOnChange: true);


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

            var threadCountInString = Configuration.GetSection("ThreadCount").Value;

            var threadCount = threadCountInString != null?Convert.ToInt32(threadCountInString) : 200;

            ThreadPool.SetMinThreads(threadCount, threadCount);

            Env = env;
        }
示例#8
0
        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnvironment)
        {
            _appEnvironment = appEnvironment;
            _hostingEnvironment = env;

            var RollingPath = Path.Combine(appEnvironment.ApplicationBasePath, "logs/myapp-{Date}.txt");
            Log.Logger = new LoggerConfiguration()
                .WriteTo.RollingFile(RollingPath)
                .CreateLogger();
            Log.Information("Ah, there you are!");

            // Set up configuration sources.
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json")
                .AddJsonFile("appsettings-filters.json")
                .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();

            // Initialize the global configuration static
            GlobalConfigurationRoot.Configuration = Configuration;
        }
示例#9
0
        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            //Setting up configuration builder
            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                .AddEnvironmentVariables();

            if (!env.IsProduction())
            {
                builder.AddUserSecrets();
            }
            else
            {

            }

            Configuration = builder.Build();

            //Setting up configuration
            if (!env.IsProduction())
            {
                var confConnectString = Configuration.GetSection("Data:DefaultConnection:ConnectionString");
                confConnectString.Value = @"Server=(localdb)\mssqllocaldb;Database=GetHabitsAspNet5;Trusted_Connection=True;";

                var identityConnection = Configuration.GetSection("Data:IdentityConnection:ConnectionString");
                identityConnection.Value = @"Server=(localdb)\mssqllocaldb;Database=GetHabitsIdentity;Trusted_Connection=True;";
            }
            else
            {

            }
        }
示例#10
0
        private static IConfigurationRoot BuildConfig()
        {
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            if (builder.GetFileProvider().GetFileInfo("project.json")?.Exists == true)
            {
                builder.AddUserSecrets();
            }
            return builder.Build();
        }
示例#11
0
 public StartupDevelopment(IHostingEnvironment env)
 {
     var builder = new ConfigurationBuilder()
        .SetBasePath(env.ContentRootPath)
        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
        .AddEnvironmentVariables();
        // Add the user secrets
         builder.AddUserSecrets();
         Configuration = builder.Build();
 }
示例#12
0
        public Startup(IHostingEnvironment env)
        {
            // Set up configuration sources.
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json")
                .AddEnvironmentVariables();

            builder.AddUserSecrets();

            Configuration = builder.Build();
        }
示例#13
0
 public Startup(IHostingEnvironment env)
 {
     var builder = new ConfigurationBuilder()
         .SetBasePath(env.ContentRootPath)
         .AddJsonFile("appsettings.json")
         .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
     if (!env.IsDevelopment())
     {
         builder.AddUserSecrets();
     }
     Configuration = builder.Build();
 }
示例#14
0
 public Startup(IHostingEnvironment env)
 {
     var builder = new ConfigurationBuilder()
         .AddJsonFile("config.json");
     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();
 }
示例#15
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("config.json");

            if (env.IsDevelopment())
            {
                builder.AddUserSecrets();
            }

            _config = builder.Build();
        }
示例#16
0
        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            var builder = new ConfigurationBuilder().SetBasePath(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json")
                .AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);

            if (env.IsDevelopment())
            {
                builder.AddUserSecrets();
            }
            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
示例#17
0
        /// <summary>
        /// 1. Loads configurations
        /// </summary>
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder();

            // general config file
            builder.AddJsonFile("config.json");
            // environment-specific config
            builder.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
            // sensitive information config
            if (env.IsDevelopment()) builder.AddUserSecrets();

            Configuration = builder.Build();
        }
示例#18
0
        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json")
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                .AddEnvironmentVariables();
            builder.AddUserSecrets();

            if (env.IsEnvironment("Development"))
            {
                builder.AddApplicationInsightsSettings(developerMode: true);
            }
            Configuration = builder.Build();
        }
示例#19
0
        public Startup(IHostingEnvironment env) {
            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();
        }
示例#20
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json")
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

            if (env.IsDevelopment())
            {
                builder.AddUserSecrets();
            }

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
示例#21
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                .AddEnvironmentVariables();

            if (env.IsDevelopment())
            {
                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets("aspnet5-Rinsen.Web-20150804040342");
            }

            Configuration = builder.Build();
        }
示例#22
0
 public Startup(IHostingEnvironment env)
 {
     var builder = new ConfigurationBuilder()
         .SetBasePath(env.ContentRootPath)
         .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
         .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
     ;
     if (env.IsDevelopment()) {
         builder.AddUserSecrets();
         // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
         builder.AddApplicationInsightsSettings(developerMode: true);
     }
     builder.AddEnvironmentVariables();
     Configuration = builder.Build();
 }
示例#23
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()//設定檔建構器
                .SetBasePath(env.ContentRootPath)//設定根目錄
                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)//加入Json類型的設定檔如果有的話,並且檔案變更時重新自動載入
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);//加入Json類型且為特定執行環境的設定檔如果有的話

            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();//建構設定檔
        }
示例#24
0
        public Startup(IHostingEnvironment env)
        {
            // Set up configuration sources.
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json")
                .AddEnvironmentVariables();

            if (env.IsDevelopment())
            {
                // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
                builder.AddApplicationInsightsSettings(developerMode: true);
                builder.AddUserSecrets();
            }
            Configuration = builder.Build();
        }
示例#25
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                .AddEnvironmentVariables();

            if (env.IsDevelopment())
            {
                builder.AddUserSecrets();
            }
            Configuration = builder.Build();
            _signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(Configuration["SecretKey"]));
        }
示例#26
0
        public Startup(IHostingEnvironment env) {

            // Set up configuration sources.
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json");

            if (env.IsDevelopment()) {

                // This reads the configuration keys from the secret store.
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();
            }

            builder.AddEnvironmentVariables();
            this.Configuration = builder.Build();
        }
示例#27
0
 public Startup(IHostingEnvironment env)
 {
     // Set up configuration sources.
     env.EnvironmentName = "Development";
     var builder = new ConfigurationBuilder()
         .SetBasePath(env.ContentRootPath)
         .AddJsonFile("appsettings.json")
         .AddEnvironmentVariables();
     
     if(env.IsDevelopment())
     {
         builder.AddUserSecrets();
     }    
     
     Configuration = builder.Build();
 }
示例#28
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

            if (env.IsDevelopment())
            {
                builder.AddUserSecrets();
                builder.AddApplicationInsightsSettings(developerMode: true);
            }

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
示例#29
0
        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            applicationPath = appEnv.ApplicationBasePath;

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

            if (env.IsDevelopment())
            {
                builder.AddUserSecrets();
            }

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
示例#30
0
        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            // Set up configuration sources.
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json")
                .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();

        }
示例#31
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

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

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
            _env          = env;
        }
示例#32
0
        public Startup(IHostingEnvironment environment, ILoggerFactory loggerFactory)
        {
            _environment = environment;
            var builder = new ConfigurationBuilder()
                .SetBasePath(environment.ContentRootPath)
                .AddJsonFile("appsettings.json")
                .AddEnvironmentVariables();

            if (_environment.IsDevelopment())
                builder.AddUserSecrets();

            _configuration = builder.Build();

            loggerFactory.AddConsole();
            loggerFactory.AddDebug();
            _logger = loggerFactory.CreateLogger<Startup>();
        }
示例#33
0
        private IConfiguration SetupConfiguration()
        {
            var existingConfiguration = Builder.Services.First(z => z.ServiceType == typeof(IConfiguration))
                                        .ImplementationInstance as IConfiguration;

            var configurationBuilder = new MsftConfigurationBinder();

            configurationBuilder.AddConfiguration(existingConfiguration);

            configurationBuilder
            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
            .AddYamlFile("appsettings.yml", optional: true, reloadOnChange: true)
            .AddJsonFile($"appsettings.{_environment.EnvironmentName}.json", optional: true, reloadOnChange: true)
            .AddYamlFile($"appsettings.{_environment.EnvironmentName}.yml", optional: true, reloadOnChange: true);

            var cb = new ConfigurationBuilder(
                Scanner,
                _environment,
                existingConfiguration,
                configurationBuilder,
                _logger,
                Properties);

            cb.Build();

            if (_environment.IsDevelopment() && !string.IsNullOrEmpty(_environment.ApplicationName))
            {
                var appAssembly = Assembly.Load(new AssemblyName(_environment.ApplicationName));
                if (appAssembly != null)
                {
                    configurationBuilder.AddUserSecrets(appAssembly, optional: true);
                }
            }

            configurationBuilder.AddEnvironmentVariables();

            var newConfig = configurationBuilder.Build();

            Builder.Services.Replace(ServiceDescriptor.Singleton <IConfiguration>(newConfig));
            return(newConfig);
        }
        public static IConfiguration GetConfiguration(IHostEnvironment env)
        {
            if (_configuration == null)
            {
                var configBuilder = new ConfigurationBuilder()
                                    .SetBasePath(env.ContentRootPath)
                                    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                    .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                                    .AddEnvironmentVariables()
                ;

                if (env.IsDevelopment())
                {
                    configBuilder.AddUserSecrets <TStartup>(optional: true);
                }

                _configuration = configBuilder.Build();
            }

            return(_configuration);
        }
示例#35
0
        private IConfiguration SetupConfiguration()
        {
            var currentDirectory = Environment.GetEnvironmentVariable("AzureWebJobsScriptRoot") ?? "/home/site/wwwroot";
            var isLocal          = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID")) &&
                                   !Directory.Exists(currentDirectory);

            if (isLocal)
            {
                currentDirectory = Environment.CurrentDirectory;
            }

            var existingConfiguration = Builder.Services.First(z => z.ServiceType == typeof(IConfiguration))
                                        .ImplementationInstance as IConfiguration;

            var configurationOptions = this.GetOrAdd(() => new ConfigurationOptions());

            var configurationBuilder = new MsftConfigurationBuilder()
                                       .SetBasePath(currentDirectory)
                                       .AddConfiguration(existingConfiguration)
                                       .Apply(configurationOptions.ApplicationConfiguration)
                                       .Apply(configurationOptions.EnvironmentConfiguration, _environment.EnvironmentName)
                                       .Apply(configurationOptions.EnvironmentConfiguration, "local");

            if (_environment.IsDevelopment())
            {
                configurationBuilder.AddUserSecrets(FunctionsAssembly, true);
            }

            configurationBuilder
            .AddEnvironmentVariables("RSG_")
            .AddEnvironmentVariables();

            IConfigurationSource?source = null;

            foreach (var item in configurationBuilder.Sources.Reverse())
            {
                if ((item is EnvironmentVariablesConfigurationSource env && (string.IsNullOrWhiteSpace(env.Prefix) ||
                                                                             string.Equals(env.Prefix, "RSG_", StringComparison.OrdinalIgnoreCase))) ||
                    (item is JsonConfigurationSource a && string.Equals(
                         a.Path,
                         "secrets.json",
                         StringComparison.OrdinalIgnoreCase
                         )))
                {
                    continue;
                }

                source = item;
                break;
            }

            var index = source == null
                ? configurationBuilder.Sources.Count - 1
                : configurationBuilder.Sources.IndexOf(source);

            var cb = new ConfigurationBuilder(
                Scanner,
                _environment,
                new MsftConfigurationBuilder().AddConfiguration(existingConfiguration !)
                .AddConfiguration(configurationBuilder.Build()).Build(),
                configurationBuilder,
                _logger,
                Properties
                );

            configurationBuilder.Sources.Insert(
                index + 1,
                new ChainedConfigurationSource
            {
                Configuration = cb.Build()
            }
                );

            var newConfig = configurationBuilder.Build();

            Builder.Services.Replace(ServiceDescriptor.Singleton <IConfiguration>(newConfig));
            return(newConfig);
        }