{"action":"closed","issue":{"url":"https://api.github.com/repos/aspnet/Home/issues/1928","repository_url":"https://api.github.com/repos/aspnet/Home","labels_url":"https://api.github.com/repos/aspnet/Home/issues/1928/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Home/issues/1928/comments","events_url":"https://api.github.com/repos/aspnet/Home/issues/1928/events","html_url":"https://github.com/aspnet/Home/issues/1928","id":206004800,"number":1928,"title":"Configuration.GetSection destroys Configuration[\"YYY\"]","user":{"login":"Eneuman","id":12099277,"avatar_url":"https://avatars.githubusercontent.com/u/12099277?v=3","gravatar_id":"","url":"https://api.github.com/users/Eneuman","html_url":"https://github.com/Eneuman","followers_url":"https://api.github.com/users/Eneuman/followers","following_url":"https://api.github.com/users/Eneuman/following{/other_user}","gists_url":"https://api.github.com/users/Eneuman/gists{/gist_id}","starred_url":"https://api.github.com/users/Eneuman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eneuman/subscriptions","organizations_url":"https://api.github.com/users/Eneuman/orgs","repos_url":"https://api.github.com/users/Eneuman/repos","events_url":"https://api.github.com/users/Eneuman/events{/privacy}","received_events_url":"https://api.github.com/users/Eneuman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-02-07T20:28:01Z","updated_at":"2017-02-07T20:32:22Z","closed_at":"2017-02-07T20:32:22Z","body":"I have a web application with a startup.cs that looks something like this:\r\n\r\n```\r\npublic Startup(IHostingEnvironment env)\r\n    {\r\n      var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder()\r\n          .SetBasePath(env.ContentRootPath)\r\n          .AddJsonFile(\"appsettings.json\", optional: true, reloadOnChange: true)\r\n          .AddJsonFile($\"appsettings.{env.EnvironmentName}.json\", optional: true)\r\n          .AddEnvironmentVariables();\r\n\r\n      if (env.IsDevelopment())\r\n      {\r\n        // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.\r\n        builder.AddApplicationInsightsSettings(developerMode: true);\r\n      }\r\n\r\n      var config = builder.Build();\r\n\r\n      // Add key vault configuration if not in local development mode\r\n      if (!env.IsDevelopment())\r\n      {\r\n        builder.AddAzureKeyVault($\"https://{config[\"KeyVault:Vault\"]}.vault.azure.net/\", config[\"KeyVault:ClientId\"], config[\"KeyVault:ClientSecret\"]);\r\n      }\r\n\r\n      Configuration = builder.Build();\r\n    }\r\n\r\npublic void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider)\r\n    {\r\n\r\n      loggerFactory.AddConsole(Configuration.GetSection(\"Logging\"));\r\n      loggerFactory.AddDebug();\r\n\r\n      app.UseCors(policy =>\r\n      {\r\n        policy.WithOrigins(Configuration[\"AppSettings:CorsOrigins\"]);\r\n        policy.AllowAnyHeader();\r\n        policy.AllowAnyMethod();\r\n        policy.WithExposedHeaders(\"WWW-Authenticate\");\r\n      });\r\n}\r\n```\r\n\r\nAfter publishing it to Azure, and restarting the site I noticed that Cors origins was not set correctly.\r\nI added a IConfiguration to one of my MVC Controls and returned the value of Configuration[\"AppSettings:CorsOrigins\"]. The value looked fine but CORS wasn't working.\r\n\r\nI decided to hard code the domain in the WithOrigins option and publish again. Now everything was working fine. After removing the hard coded values and restore my configuration it stoped working again.\r\n\r\nI decided to exclude any code that might interfere with the Configuration object and when I removed:\r\n\r\n```\r\n     loggerFactory.AddConsole(Configuration.GetSection(\"Logging\"));\r\n      loggerFactory.AddDebug();\r\n```\r\neverything started to work again. Somehow, Configuration.GetSection or the loggerFactory does something to the Configuration so it doesn't work as expected afterwards. But using IConfiguration later in a controller seems to work.\r\n\r\nAm I missing something here or is this a bug?\r\n\r\n(VS 2017 latest Tooling, .Net Core 1.1.0)"}}
{"actor":{"display_login":"Tratcher"}}