Getting Started with AWS

Deploy a .NET Web Application on Amazon ECS powered by Graviton2

Module 5: Deploy the Application to Amazon ECS

In this module, you will launch new Tasks under Amazon ECS Service


So far in the guide you have prepared the foundational environment for your sample application in Module 1 and Module 2. In Module 3 you built and published the Docker image for the sample application, and in Module 4 you created the building blocks required to launch a Load Balanced Amazon ECS Service that will instantiate tasks behind the AWS Application Load Balancer.

What You Will Learn

  • You’ll learn how to launch new Tasks under Amazon ECS Service.

Key Concepts

Amazon ECS Service - An Amazon ECS service enables you to run and maintain a specified number of instances of a task definition simultaneously in an Amazon ECS cluster. If any of your tasks should fail or stop for any reason, the Amazon ECS service scheduler launches another instance of your task definition to replace it in order to maintain the desired number of tasks in the service. For more information on services, see Amazon ECS services.

 Time to Complete

10 minutes

 Services Used


  • 1. Select the Cluster - Graviton2ECSCluster.

    ECS select cluster

    2. Under the Services Tab, click Deploy button.

    3. Under the Environment Section, expand Compute Configuration (advanced) section.

    4. Select the Cluster you created (should already be selected) i.e. Graviton2ECS.

    5. Select Launch Type as EC2 from the dropdown.

    ECS select launch type

    6. Under Deployment configuration section select Service, and under Task definition - Family select the task you created - Graviton2ECSTask, and Revision as LATEST.

    7. Enter name as Graviton2ECSService.

    8. Enter value for Desired Tasks to be 2, as shown in the screenshot below:

    ECS select application type

    Stay on the same screen, you’ll set up Load Balancing for the Service.

  • 1. Expand Load balancing - optional section, select Create a new load balancer and enter name as Graviton2ECSALB.

    2. Ensure Listener Port is 80 and Protocol HTTP.

    3. Enter Target group name as Graviton2ECS-ALB-TG and protocol as HTTP.

    EC2 create a new Load Balancer
  • 1. In the Networking section, select TargetVPC under the VPC dropdown.

    2. Select public subnets - TargetVPC-public-a and TargetVPC-public-b, under the Subnets dropdown, this is only required for ALB configuration. You should be able to find the subnet IDs for the these subnets in Subnets list view by searching for their names.

    3. Under Security group select - Use an existing security group and choose <CloudFormation-Stack-Name>-ALBSG security group. If you used the name suggested in Module 1, it should start with ContainerizeDotNetOnECSGraviton2-ALBSG.

    Load Balancer networking configurations

    4. Leave rest of the settings to default.

    5. Click Deploy button. Service deployment can take a few minutes. Once finished the Cluster will look like below:

    ECS deploy service

    6. Click on Service Graviton2ECSService from the list of Services to view the Tasks running, Health check status and notifications.

    ECS Service health check status

    You can note the Desired and Running count to verify that ECS Service has successfully instantiated desired number of tasks. At this stage, your Sample Application is live, under a single Task, behind an Application Load Balancer.

  • Sample .NET web application has Login Functionality, which enables logged-in user to edit the records, stored in Aurora DB.

    For the session management, this guide takes the simplest route by enabling sticky session, instead of adding complexity in the .NET sample app.

    Sticky sessions are a mechanism to route requests from the same client to the same target. Elastic Load Balancers support sticky sessions. Stickiness is defined at a target group level.

    So the next step is to modify the Load balancing target group created by the ECS Service - Graviton2ECS-ALB-TG, and enable Session stickiness.

    1. Go to EC2 from the Services drop down in the top navigation or search for EC2, click on Target Groups from Load Balancing category in the left hand side navigation pane.

    2. Choose the name of Graviton2ECS-ALB-TG target group to open its details page.

    3. On the Group details tab, in the Attributes section, choose Edit.

    Load Balancer edit attributes

    On the Edit attributes page, 

    4. Select Stickiness.

    5. For Stickiness type, select Load balancer generated cookie.

    6. For Stickiness duration, leave the default value of 1 day.

    7. Choose Save changes.

    Load Balancer enable Sticky Session
  • Now the application is ready for testing, and you need to find the public facing URL of the application, which is the DNS Name of the Application Load Balancer created by ECS Service.

    1. Staying on EC2 Service console, click on Load Balancers on the left side Navigation pane, and select Graviton2ECSALB.

    2. Copy the value of DNS Name as shown below:

    Load Balancer copy DNS name

    3. Open the copied URL in a new Browser window, It should open the Sample application.

    Web Application landing page

    Application is in read-only for anonymous users, to be able to modify the data, you can login to the application using following admin credentials:

    • Username: admin
    • Password: Pass@word1

    When you logged in for the first time, application asks you to set a new password for your user, choose a new password and continue. 

    Web Application set new password

    This step completes the deployment of Sample .NET Web Application on Amazon ECS.

Application Architecture

Here is what your architecture looks like right now:

Architecture module 5


You have now successfully containerised and deployed a .NET application on Graviton2 instance via Amazon Elastic Container Service

Was this module helpful?

Monitoring and Logging