Running your ASP.NET Core application on Azure Container Service

While preparing for my Techdays session about “How ASP.NET Core and Docker will change the life of a Microsoft Developer” I was experimenting a bit with Azure Container Service and running my ASP.NET Core application on the ACS Cluster.

Together with my colleague Alex Thissen and with some help of my Xebia Colleague Mark van Holsteijn I managed to set up a ACS cluster with DCOS. Within the cluster we use the Marathon Load Balancer (marathon-lb) to redirect the traffic within the cluster to the specific container,

In this post I will describe a step by step to setup the ACS Cluster and run a simple application on it.

Generating SSH Keys

FIrst you need to have an SSH client installed and have some SSH keys that you can use. I use Putty and PuttyGen. To generate keys follow this great guide that describe the steps in detail.

https://docs.joyent.com/public-cloud/getting-started/ssh-keys/generating-an-ssh-key-manually/manually-generating-your-ssh-key-in-windows

Spinning up the cluster

Go the Azure Portal and spin up a new Azure Container Service Cluster. Make sure you paste in the SSH public key you just created and spin up 3 agents.

Set up an SSH tunnel and connect to DCOS

When the cluster has been created you need to set up a SSH tunnel to be able to connect to it. Open Putty and fill in the session details

Session Tab
Host name / IP Address: The DNS name or IP of the DCOS master
Port: 2200

SSH / Tunnels
Create a port forwarding for port 80

image

SSH / Auth
Select the Private Key that you generated and point to it

Do not forget to save your session!

image

image

Configure the Marathon-LB Load Balancer

Navigate to the Universe on the left side, and search for marathon-lb. Choose install and select advanced installation. Check if the HAPROXY_GROUP is set to external

image

When you hit Review and install, the load balancer is being deployed.

Deploy your first ASP.NET Core Docker container

When the load balancer is configured, you can deploy your first application. For convenience, I created a Docker container with an ASP.NET Core Web Application inside. You can pull this image from Dockerhub with the tag rvanosnabrugge/tdweb

If you want to test this on a local Linux host just run the command

docker run –d –p 8080:80 rvanosnabrugge/tdweb

Then you can access the web application on localhost:8080

In the DCOS Services tab, open Marathon to manage your application.

image

In Marathon, add a new application and configure it

image

On the Docker Container Tab, point to the Docker container rvanosnabrugge/tdweb, set the Network to Bridged,

image

On the Ports and Discovery Tab, Add Port 80 to expose the port inside the container to the cluster

image

On the Labels tab we need to link this container to the Marathon Load Balancer. Add a Label

HAPROXY_GROUP and set the value to external (this label is also present on the marathon-lb)

HAPROXY_0_VHOST and set the value to a DNS name. You can use the service xip.io to get a DNS name. Just choose a name and add the IP. Something like tdweb.<IP ADDRESS>.xip.io.

For IP Address use the IP address of the Load Balancer of the agents. This can be found in t the Azure Portal.

image

When you hit Create Application, the Container is deployed.

Open a browser and navigate to the XIP.IO address(tdweb.<IP ADDRESS>.xip.io. ) that you created and Voila!

You can now scale up and scale down your container (s) on the cluster!

Good luck !

Advertisements

3 Responses to “Running your ASP.NET Core application on Azure Container Service”

  1. Hi,
    I tried all the steps as mentioned in the document.But not able to browse application.
    Can you please help in this by providing any internal settings which i should set in dcos or azure container service(such as enabling any port).

Trackbacks/Pingbacks

  1. Dew Drop - December 28, 2016 (#2393) - Morning Dew - December 28, 2016

    […] Running your ASP.NET Core application on Azure Container Service (Rene van Osnabrugge) […]

%d bloggers like this: