title: How to get DotNet Core ApplicationName set by Environment Variable
body: <p>According to the .NET Core <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/web-host?view=aspnetcore-2.1#application-key-name" rel="nofollow noreferrer">documentation</a>, I should be able to set the application name using an environment variable.</p>
  
  <blockquote>
    <p>Environment variable: ASPNETCORE_APPLICATIONKEY</p>
  </blockquote>
  
  <p>I am not seeing this to be the case.  I added the <code>WebHostDefaults.ApplicationKey</code> setting to the <code>Program.cs</code> but I am still unable to override it with an environment variable.</p>
  
  <pre><code>    private static IWebHost BuildWebHost(string[] args)
      {
          var config = new ConfigurationBuilder()
              .SetBasePath(Directory.GetCurrentDirectory())
              .AddJsonFile("hosting.json", true)
              .AddEnvironmentVariables("ASPNETCORE_")
              .AddCommandLine(args)
              .Build();
  
          return WebHost.CreateDefaultBuilder(args)
              .ConfigureLogging((context, builder) =&gt; { builder.ClearProviders(); })
              .UseConfiguration(config)
              .PreferHostingUrls(true)
              .UseStartup&lt;Startup&gt;()
              .UseSetting(WebHostDefaults.ApplicationKey, "CustomApplicationName")
              .Build();
      }
  </code></pre>
  
  <p>In <code>startup.cs</code> I am only seeing "CustomApplicationName" rather than the environment variable.</p>
  
  <pre><code>public class Startup
  {
      public Startup(IConfiguration configuration, IHostingEnvironment hostingEnvironment)
      {
          Configuration = configuration;
          Log.Information($"Startup of application {hostingEnvironment.ApplicationName} in Environment Mode {hostingEnvironment.EnvironmentName}");
      }
  }
  </code></pre>
  
  <p>I have tried using double underscore in the environment variable name as well.</p>
  
  <p>I am running on Mac OS.</p>