AWS .NET SDK
AWS Guide for .NET Developers

Deploying an ASP.NET Core 2.0 App to Amazon Elastic Container Service

This section describes how to use the Publish Container to AWS wizard, provided as part of the Toolkit for Visual Studio, to deploy a containerized ASP.NET Core 2.0 application targeting Linux to Amazon ECS using the Fargate launch type. Because a web application is meant to run continuously, it will be deployed as a service.

Access the Publish Container to AWS Wizard

To deploy an ASP.NET Core 2.0 containerized application targeting Linux, right-click the project in Solution Explorer, and then choose Publish Container to AWS.

You can also choose Publish Container to AWS on the Visual Studio Build menu.

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 page.

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

  6. Choose Enable Docker Support, choose Linux as the operating system, and then choose OK. Visual Studio 2017 generates the project.

Use the Publish Container to AWS Wizard

  1. In Solution Explorer, open the context (right-click) menu for the WebAppDemo project folder for the project you created in the previous section, or open the context menu for the project folder for your own application, and then choose Publish Container to AWS.

    The Publish Container to AWS... wizard appears.

  2. In Profile, in 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 can 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 US East (N. Virginia) or another region offering Fargate.

  4. Choose Service on an ECS Cluster as the Deployment Target. Ensure Save settings to aws-ecs-tools-defaults.json and configure project for command line deployment is selected. You can use the settings file

    to make future deployment from the command line using the .NET CLI.

  5. On the Launch Configuration page, in the ECS Cluster list, choose Create an empty cluster, and then name the cluster WebAppDemo. Verify Launch Type is set to FARGATE.

  6. In the Network Configuration area, choose Create New to create a new security group, and then choose Next.

  7. On the Service Configuration page, in the Service list, choose Create New. The wizard provides a default service name.

  8. Update the Number of Tasks to 2. Each task maps to an instance of your container. If one goes down, the other can be available. Choose Next

  9. On the Application Load Balancer Configuration page, choose Configure Application Load Balancer. In the Load Balancer list, choose Create New. The wizard provides defaults for related fields. Choose Next.

  10. On the Application Load Balancer Configuration page, in the Task Definition list, choose Create New. The Container list should also be set to Create New. Accept the default names and other values.

  11. Choose Publish.

    Note

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

    Events are displayed during deployment. The wizard is automatically closed on successful completion. You can override this by unchecking the box at the bottom of the page.

    You can find the URL of your new instances in the AWS Explorer. Expand Amazon ECS, then expand Clusters, and then click on your cluster.