Running .NET Core apps in Docker containers on AWS

Do you need a cross platform performant app that can run in the cloud, be performant, can easily scale and can be started quickly?

Nowadays, with .NET Core we have an open source cross platform optimized framework in which we can build apps quickly and with Docker we have the necessary operation system virtualization and a platform that is based on the microservice architecture built with mind to develop lightweight, secure, extensible application without worrying about the physical servers. Taking into consideration that with Docker we can run multiple building blocks (containers) independently and on every platform (Windows, Linux, Mac) makes this even greater solution.

One of the major players in the market where we can put our solution is Amazon Web Services (AWS) and the actual service that is compatible for this kind of solution is the Elastic Container Service (ECS).

On the last Re:Invent (November 2017), Amazon Web Services pre-announced the new technology AWS Fargate that from this year is available – AWS Elastic Container Service (ECS).

AWS Elastic Container service is a scalable, performant cloud computing container orchestration service that supports Docker and allows running containerized apps on AWS. With the new Fargate technology we can run containers without managing servers or clusters.

So, how can we start? The simplest way to start is by using the Visual Studio Docker template and Visual Studio AWS Toolkit.

Running .NET Core apps in Docker containers on AWS

 

The Visual Studio Docker template project comes with already created Dockerfile (docker configuration blueprint) and this project is detected by the AWS Toolkit as a container project. From this point we can easily publish our project using the AWS Toolkit.

Running .NET Core apps in Docker containers on AWS

When it comes to the docker image details there is a very easy way to specify the image name, docker repository and tag in a user friendly environment of the AWS toolkit which in the background executes docker native cli commands.

Running .NET Core apps in Docker containers on AWS

For the ECS launch specific configuration there is an additional configuration section where we sepcify the cluster name, launch type, compute capacity configuration and network configuration.

Running .NET Core apps in Docker containers on AWS

Also using the toolkit there is an easy configuration for the container services, number of tasks and application load balancing.

After just a few minutes we have functional app up and running with the public DNS endpoint. Hooray!

 

Conclusion

Using .NET core in docker containers is the right choice because it gives us performance, isolation, extensibility and easily configurable environment to work with. With AWS Elastic Container Service (ECS) and Fargate technology we don’t have to worry about where our application will run and how to configure it. We can focus and concentrate on developing our app from day 0 which gives us great advantage especially when we are using .NET Core with Visual Studio as an IDE.