title: Getting value from appSettings.json?
body: <p>I'm unable to retrieve the value set in appsettings.json, when I run the code below, I get an error <code>System.NullReferenceException: 'Object reference not set to an instance of an object.'</code></p>
  
  <p>What am I doing wrong?</p>
  
  <pre><code>public static IConfigurationRoot Configuration { get; } 
  ....
  string facebookApiId = Configuration.GetValue&lt;string&gt;("Authentication:Facebook:AppId");
  </code></pre>
  
  <p><strong>appSettings.json</strong></p>
  
  <pre><code>"Authentication": {
    "Facebook": {
      "IsEnabled": "false",
      "AppId": "somevalue1",
      "AppSecret": "somevalue2"
    },
    "Google": {
      "IsEnabled": "false",
      "ClientId": "somevalue3",
      "ClientSecret": "somevalue4"
    }
  </code></pre>
  
  <p><strong>Startup.cs</strong></p>
  
  <pre><code>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)
          .AddEnvironmentVariables();
      Configuration = builder.Build();
  }
  
  public IConfigurationRoot Configuration { get; }
  </code></pre>