AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)
AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Configuring .NET Environments with Elastic Beanstalk

When deploying your .NET application, you might want to customize and configure the behavior of your Amazon EC2 instances. You can easily customize your instances at the same time that you deploy your application version by including a configuration file with your source bundle. You might also want to customize your environment resources that are part of your Elastic Beanstalk environment (for example, Amazon SQS queues or Amazon ElastiCache clusters). For example, you might want to add an Amazon SQS queue and an alarm on queue depth, or you might want to add an Amazon ElastiCache cluster. This section walks you through the process of creating a configuration file and bundling it with your source.

To access the software configuration for your Elastic Beanstalk environment

  1. Open the Elastic Beanstalk console.

  2. Navigate to the management page for your environment.

  3. Choose Configuration.

  4. In the Software Configuration section, choose the settings icon ( Edit ).

For your application's version Framework, you can choose either 2.0 or 4.0. Select Enable 32-bit Applications if you plan to run 32-bit applications.

Elastic Beanstalk can copy the log files for your application's Amazon EC2 instances to the Amazon S3 bucket associated with your application on an hourly basis. To enable this feature, select Enable log file rotation to Amazon S3.

The Environment Properties section lets you specify environment variables that you can read from your application code. This setting enables greater portability by eliminating the need to recompile your source code as you move between environments.

To customize and configure your .NET environment

  1. Create a configuration file with the extension .config (for example, myapp.config) and place it in an .ebextensions top-level directory of your source bundle. You can have multiple configuration files in your .ebextensions directory. For information about the file format and contents of the configuration file, see Configuration Files (.ebextensions).


    For Visual Studio, .ebextensions needs to be part of the project to be included in the archive. Alternatively, instead of including the configuration files in the project, you can use Visual Studio to deploy all files in the project folder. In Solution Explorer, right-click the project name, and then click Properties. Click the Package/Publish Web tab. In the Items to deploy section, select All Files in the Project Folder in the drop-down list.

    The following is an example snippet of a configuration file.

    # If you do not specify a namespace, the default used is aws:elasticbeanstalk:application:environment
        command: set > c:\\myapp\\set.txt
        leader_only: true
    	waitAfterCompletion: 0
      - option_name: PARAM1
        value: somevalue


    You can specify any key–value pairs in the aws:elasticbeanstalk:application:environment namespace, and they are available as environment variables on your Amazon EC2 instances.

  2. Deploy your application version.

Accessing Environment Configuration Settings

The parameters specified in the option_settings section of the configuration file are passed in and used as application settings.

You might have a code snippet that looks similar to the following to access the keys and parameters:

NameValueCollection appConfig = ConfigurationManager.AppSettings;
string param1 = appConfig["PARAM1"];


Environment configuration settings can contain any printable ASCII character except the grave accent (`, ASCII 96) and cannot exceed 200 characters in length.

For a list of configuration settings, see .NET Platform Options.