AWS Elastic Beanstalk environment variables in ASP.NET Core 1.0

后端 未结 9 2008
误落风尘
误落风尘 2020-12-01 02:59

How do I get environment variables from elastic beanstalk into an asp.net core mvc application? I have added a .ebextensions folder with app.config file in it with the follo

9条回答
  •  失恋的感觉
    2020-12-01 03:24

    Instead of having to parse the containerconfiguration you can leverage the ebextensions options to set the variable as part of your deploy process:

    commands:
      set_environment: 
        command: setx ASPNETCORE_ENVIRONMENT "Development" /M
    

    This will set a global environment variable as part of your application deployment. This variable use-case is officially supported and documented by Microsoft.

    After deploying your app you can verify the setting is set correctly in the EC2 instance:

提交回复
热议问题