Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Latest commit

 

History

History
32 lines (24 loc) · 1.45 KB

File metadata and controls

32 lines (24 loc) · 1.45 KB

AWS now supports retrieving the values of Environment Properties for .NET Core applications. Environment Variables with .NET Core and Elastic Beanstalk

[DEPRECATED] RockLib.ElasticBeanstalk Build status

PM> Install-Package RockLib.ElasticBeanstalk

Elastic Beanstalk does not provide a mechanism for .NET Core applications to retrieve the values of its Environment Properties. The RockLib.ElasticBeanstalk package implements a workaround that maps Environment Properties to the current process's environment variables.

Call the EnvironmentProperties.MapToEnvironmentVariables method at the very beginning of your application. In ASP.NET Core applications, it is important to do this before creating the IWebHost, since the default configuration reads environment variables.

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using RockLib.ElasticBeanstalk

class Program
{
    static void Main(string[] args)
    {
        EnvironmentProperties.MapToEnvironmentVariables();
        
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .Build();
}