KOSD, or Kopi-O Siew Dai, is a type of Singapore coffee that I enjoy. It is basically a cup of coffee with a little bit of sugar. This series is meant to blog about technical knowledge that I gained while having a small cup of Kopi-O Siew Dai.
Last month, after sharing the concepts and use cases of Domain Driven Development, Riza moved on to talk about Containers in the sharing session of Singapore .NET Developers Community.
![microservices-not-equal-to-containers.png](https://cuteprogramming.blog/wp-content/uploads/2017/12/microservices-not-equal-to-containers.png?w=685)
Learning Motivation
In the beginning of Riza’s talk, he mentioned GO-JEK, an Indonesia ride-hailing phone service. Due to their rapid growth, the traditional monolithic architecture can no longer support their business. Hence, they switched to use a modern approach which includes moving apps to containers.
![go-jek-containers.png](https://cuteprogramming.blog/wp-content/uploads/2017/12/go-jek-containers.png?w=481&h=516)
Hence, after the meetup, I was very excited to find out more about micro-services and Docker containers. With the ability of .NET Core to be cross-platform, as a Azure lover, I am interested to find out more how I can deploy ASP .NET Core web app to a container in Azure. So, I decided to write this short article to share with my teammates about this that they can learn while drinking a cup of coffee.
Creating New Project with Docker Support
Since I am trying it out as personal project, I choose to start it with a new ASP .NET Core project. Then in the Visual Studio, I can easily turn it to be a Docker supporting app easily by checking the “Enable Docker Support” option.
![enable-docker-support.png](https://cuteprogramming.blog/wp-content/uploads/2017/12/enable-docker-support.png?w=685)
For existing web application projects, we will not have the screen above. Luckily, it is still easy to add Docker Support to an existing ASP .NET Core project on Visual Studio.
![add-docker-support-to-existing-project](https://cuteprogramming.blog/wp-content/uploads/2017/12/add-docker-support-to-existing-project1.png?w=685)
Then by clicking on the “F5” button to run the project, I manage to get the following screen (The background is customized by me). The message is displayed using the following line.
System.Runtime.InteropServices.RuntimeInformation.OSDescription;
![launched-at-localhost.png](https://cuteprogramming.blog/wp-content/uploads/2017/12/launched-at-localhost.png?w=685)
Publishing to Microsoft Azure with Continuous Delivery
Without Continuous Delivery, we also can easily right-click the web application to publish it to the Container Registry on Azure.
![publishing-to-container-registry](https://cuteprogramming.blog/wp-content/uploads/2017/12/publishing-to-container-registry.png?w=685)
Then, on Azure Portal, we will see three new resources added. Firstly, we will have the Container Registry.
Then, we will also have an app service site which is running the image downloaded from the Container Registry. Finally, we have an App Service Plan which needs to be at least B1 because free and shared SKUs are not available for apps running on Linux (The official Microsoft documentation says we should have the VM size of the App Service Plan to be S1 or larger though).
![container-registry-on-azure.png](https://cuteprogramming.blog/wp-content/uploads/2017/12/container-registry-on-azure1.png?w=685)
To enable Continuous Delivery, I choose to use Github + Visual Studio Team Services (VSTS). By doing so, build and release will be automatically started whenever I check in code to Github.
![build-on-vsts](https://cuteprogramming.blog/wp-content/uploads/2017/12/build-on-vsts.png?w=685)
Yup, this is so far what I have tried out in my first step of playing with containers. If you are interested, please check out the references listed below.
References
- [E-Book] .NET Microservices Architecture
- [Article] Get started with Docker for Windows
- [Article] Put a .NET Core App in a Container with the new Docker Tools for Visual Studio
- [Github] eShopOnContainers – Microservices Architecture and Containers based Reference Application (BETA state – Visual Studio 2017 and CLI environments compatible)
- [E-Book] Microservices and Docker containers: Architecture, Patterns and Development guidance (Updated for .NET Core 2.0)
- [E-Book] Migrating to Microservice Databases: From Relational Monolith to Distributed Data
One thought on “[KOSD Series] First Attempt of Deploying ASP .NET Core to Azure Container Service”