Skip to main content

Deploying an ASP.NET 5 container in a Linux Virtual Machine on Azure

Scope
This articles introduces the concept of Docker containers and demonstrates how an ASP.NET 5 application can be deployed to an ASP.NET 5 container in a Linux Virtual Machine on Azure.

Prerequisite
.NET Core
.NET Core 5 is an open source stack and can run on multiple operating systems.

It is a modular implementation that can be used in several devices, is available as an open source, and is supported by Microsoft on Windows, Linux and Mac OSX.


.NET Core is not specific to either .NET Native nor ASP.NET 5. Therefore, it forms the foundation for all future .NET verticals, even additional to ASP.NET or Windows Store.

ASP.NET 5
ASP.NET 5 is now a single framework that runs on top of either .NET Core 5 runtime (Core-CLR) or the .NET Framework runtime (CLR).

ASP.NET 5 is the first workload that has adopted .NET Core. ASP.NET 5 runs on both the .NET Framework and .NET Core. 

A key value of ASP.NET 5 is that it can run on multiple versions of .NET Core 5 on the same machine. Website A and website B can run on two different versions of .NET Core on the same machine, or they can use the same version. 

Introduction 
What is Docker?

Docker allows you to package an application with all of its dependencies into a standardized unit for software development.


What are containers?

Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, and system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.





How is this different from virtual machines?
Containers have similar resource isolation and allocation benefits as virtual machines but a different architectural approach allows them to be much more portable and efficient.
                          
     Virtual Machines                                                 Docker Containers image

               

Docker Hub
The Docker Hub is a repository for building and shipping application or service containers. It provides a centralized resource for container image discovery, distribution and change management, and user and team collaboration.

Docker Files
A Docker file is a text file where you tell Docker what you want in your image. It contains all the commands a user could call on the command line to assemble an image. More details about Docker File will come in the next article of this series.

Docker and DevOps



ASP.NET Container Deployment Process


Deploying the ASP.NET App to Docker
Visual Studio 2015
In this article, Visual Studio 2015 shall be used. Click here to download it.

Visual Studio Tools for Docker
The Visual Studio 2015 Tools for Docker Preview enables developers to build and publish an ASP.NET 5 Web or console application to a Docker container running on a Linux or Windows virtual machine.

Click here to download Visual Studio Tools for Docker.

Create an ASP.NET 5 Web Site
To create a new ASP.NET Website, click on FileNew Project, then ASP.NET Web Application.



Then under ASP.NET 5 tab, select Web Site.

Deploy the Web Site

Right-Click on the project and click Publish.



If Docker tools have been installed correctly, a new option will appear in the publish window calledDocker Containers.


Form here, you may either use an existing container or create a new one.

In this example, a new container shall be created.



Next, fill in the DNS Name, User Name, and password and click OK.



Since no VM was available, a new Ubuntu VM will be provisioned after which we’ll need to publish the Web Site.

Ubuntu VM

The log of the VM creation can also be viewed in Visual Studio.

log of the VM creation

VM creation

Once the VM is created, the Web Site can be deployed. Right-Click on the project and click publish again.

This will automatically select a newly created Docker Profile with all the settings filled.

Click Publish to deploy the Web Site.

Web Site

This will perform all the steps discussed in the previous section and same can be viewed in the log.
  1. Building the project.

    Building the project
  2. Doing a Docker Build.

    Docker Build
  3. Sending the build details to the Docker Daemon.

    build details
  4. Downloading the ASP.NET image from the Docker Hub.

    Docker Hub

    Once the deployment completes, the website will open.

Conclusion & Next Steps
In this article, the basics of Docker was covered, and also demonstrated how easy it is to deploy an ASP.Net Web Site to a Docker image on a Linux VM.

In the next article, more technical details about Docker files, build and deployment via Power Shell shall be discussed.

References

Comments

Popular posts from this blog

Creating and Querying Microsoft Azure DocumentDB

DocumentDB is the latest storage option added to Microsoft Azure.
It is a no-sql storage service that stores JSON documents natively and provides indexing capabilities along with other interesting features.

This article is available available on theMicrosoft Technet Wiki. This article was highlighted in theTop Contributor awardson the 12th of October 2014. This article was highlighted in the TNWiki Article Spotlight. This article was highlighted in the The Microsoft TechNet Guru Awards! (October 2014).


DocumentDB is the latest storage option added to Microsoft Azure.
It is a no-sql storage service that stores JSON documents natively and provides indexing capabilities along with other interesting features.
This wiki shall introduce you to this new service.

Setting up a Microsoft Azure DocumentDBGo to the new Microsoft Azure Portal. https://portal.azure.com/ 


 Click on New > DocumentDB


Enter A Database ID and hit Create!



Query Unstructured Data From SQL Server Using PolyBase

Scope The following article demonstrates how unstructured data and relational data can be queried, joined and processed in a single query using PolyBase, a new feature in SQL Server 2016. Pre-RequisitesIntroduction to Big Data Analytics Using Microsoft Azure Big Data Analytics Using Hive on Microsoft Azure Analyze Twitter Data With Hive in Azure HDInsight Running Hadoop on Linux using Azure HDInsight  Introduction Traditionally, Big Data is processed using Apache Hadoop which is totally fine. But what if the result of this needs to be linked to the traditional Relation Database? For example, assume that from the analysis of tons of application logs, marketing needs to contact some customs that faced problems in an application following a failure in the application.
This problem is solved with PolyBase. PolyBase allows you to use Transact-SQL (T-SQL) statements to access data stored in Hadoop or Azure Blob Storage and query it in an ad-hoc fashion. It also lets you query semi-structure…

Creating and Deploying Microsoft Azure WebJobs

Azure WebJobs enables you to run programs or scripts in your website as background processes. It runs and scales as part of Azure Web Sites.
This article focuses on the basics of WebJobs before demonstrating an example where it can be used.

This article is also available on the Mirosoft TechNet Wiki.
This article was highlighted in the The Microsoft TechNet Guru Awards! (October 2014).


Introduction
What is Microsoft Azure WebJobs?
Azure WebJobs enables you to run programs or scripts in your website as background processes. It runs and scales as part of Azure Web Sites.

What Scheduling Options is supported by Microsoft Azure WebJobs? Azure WebJobs can run Continuously, On Demand or on a Schedule.
In what language/scripts are WebJobs written?
Azure WebJobs can be created using the following scripts:  .cmd, .bat, .exe (using windows cmd).ps1 (using powershell).sh (using bash).php (using php).py (using python).js (using node)In this article, the use of c# command line app shall be demonstrated.
Cr…