AWS Guide for .NET Developers

Deploying an ASP.NET Core 2.0 application to AWS Elastic Beanstalk

You can use the Publish to AWS Elastic Beanstalk wizard, provided as part of the Toolkit for Visual Studio, to deploy an ASP.NET Core 2.0 application targeting Windows to Elastic Beanstalk.

Create a Sample Web Application Starter Project

  1. In Visual Studio, choose File, New, Project.

  2. In the navigation pane of the New Project dialog box, expand Installed, expand Templates, expand Visual C#, and then choose Web.

  3. In the list of web project templates, choose ASP.NET Core Web Application.

  4. In the Name box, type WebAppDemo, and then choose OK to go to the next screen.

  5. Confirm NET Core and ASP.NET Core 2.0 are selected, and then select the Web Application application template.

  6. Confirm the Create directory for solution box is selected. In the Solution list, confirm Create new solution is selected, and then choose OK to go to the next page.

  7. Confirm NET Core and ASP.NET Core 2.0 are selected, and then select the Web Application application template.

Deploy an ASP.NET Core 2.0 Application Using the Publish to AWS Elastic Beanstalk Wizard

  1. In Solution Explorer, open the context (right-click) menu for the WebAppDemo project, or open the context menu for the project for your own application. Then choose Publish to AWS Elastic Beanstalk.

    The Publish to Elastic Beanstalk wizard appears.

  2. In Profile, from the Account profile to use for deployment list, choose the AWS account profile to use for the deployment. This account profile is used only for deployment. You specify other credentials separately in the wizard.

    Optionally, if you have an AWS account you want to use, but you haven't yet created an AWS account profile for it, you can choose the plus symbol (+) button to add an AWS account profile.

  3. In the Region list, choose the AWS Region to which you want Elastic Beanstalk to deploy the application.

  4. In Deployment Target, choose Create a new application environment. If you wanted to redeploy a previously deployed application, you would choose Redeploy to an existing environment.

  5. Choose Next.

    On the Application Environment page, in the Application area, the Name defaults to WebAppDemo.

  1. In the Environment area, in the Name list, choose WebAppDemo-dev. In this context, the term environment refers to the infrastructure Elastic Beanstalk provisions for your application.

  2. Choose Check availability to ensure the default URL domain EBWebAppDemo-dev for your web application isn't already in use. If it is in use, try other names until the requested URL is available.

  3. Choose Next.

  4. In the Key pair list, choose an Amazon EC2 instance key pair to use to sign in to the instances that will be used for your application. Select <Create new key pair...> and type in a key name. We have used "MyKeyPair" in this example.

    We recommend you launch your instance with a key pair so that you can connect to it with SSH or RDP in the future.

  5. Ensure Use non-default VPC, Single instance environment, and Enable Rolling Deployments are not selected. You can add these options later.

    Optionally, if you have an Amazon Relational Database Service database security group with a database you want your application to access, select it in the Relational Database Access list. It will be modified to permit access from the Amazon EC2 instances hosting your application.

    Choose Next.

  6. On the Permissions page, choose Next to accept the defaults.

  7. On the Applications Options page, choose Next to accept the defaults.

  8. On the Review page, review the options you configured. Choose Open environment status window when wizard closes and Save settings to aws-beanstalk-tools-defaults.json and configure project for command line deployment. You can use the settings file to make future deployments from the command line using the .NET CLI.

  9. If everything looks correct, choose Deploy.


    When you deploy the application, the active account will incur charges for the AWS resources used by the application.

    Information about the deployment will appear in the Visual Studio status bar and the Events window of the environment page. It might take several minutes to complete the deployment. When the complete, you'll see a green INFO event indicating that the environment launch succeeded.

    Choose the URL to view the website.

Expand Capacity

Your Elastic Beanstalk environment includes an Auto Scaling group that manages the Amazon EC2 instances in your environment. In a single-instance environment, the Auto Scaling group ensures that there is always one instance running. In a load-balanced environment, you configure the group with a range of instances to run, and Amazon EC2 Auto Scaling adds or removes instances as needed, based on load.

You can configure how Amazon EC2 Auto Scaling works by editing Capacity on the Auto Scaling page for your application in AWS Explorer.

  1. In Visual Studio 2017, select View, and then choose AWS Explorer if it is not already visible.

  2. In AWS Explorer, expand the Elastic Beanstalk node, and then double-click the node for your application environment. In this example, it's EBWebAppDemo-dev.

  3. Choose Auto Scaling.

  4. Configure automatic scaling settings. To ensure there are a minimum of two instances of your application running, adjust Minimum Instance Count to 2. You can also increase or decrease Maximum Instance Count to suit demand.

    For more information on auto scaling settings and triggers, see Auto Scaling Group.

  5. Choose Apply Changes.

Delete an AWS Elastic Beanstalk Deployment

You can use the Toolkit for Visual Studio to delete an application. In AWS Explorer, expand the Elastic Beanstalk node, open the context (right-click) menu for the application you want to delete, and then choose Delete.

You can also terminate a deployment environment. In AWS Explorer, expand the Elastic Beanstalk node, expand the node for your application, open the context (right-click) menu for the environment you want to terminate, and then select Terminate Environment. The termination process might take a few minutes. You can monitor termination status on the event tab of the environment view.