Deploy an ASP.Net Core 1.0 Docker Image to Azure Ubuntu Virtual Machine

In this tutorial, we are going to see how to deploy a Docker image created with ASP.Net Core 1.0 Application to an Ubuntu Virtual Machine created in Microsoft Azure Cloud. Docker helps us in creating packages for our application into standard images. These Docker images are ready to be deployed on Docker Containers and can run on any environment.

The power of Docker comes from its containers which wrap everything needed to run our application, for example code, runtime, dependencies, tools etc. This will ensure that our application will always run irrespective of hosting environment.

As a prerequisite for current tutorial, one has to create a Docker Image of an ASP.Net Core 1.0 Application and push the image to Docker Hub by following Create and Deploy Docker Container of ASP.Net Core 1.0 Application to Azure Linux Web Application.

Now lets get started by creating an Ubuntu Virtual Machine in Azure Cloud. Select Ubuntu Server 16.04 LTS.

image

Click Create. Fill in the required details like Name. Select Password as the Authentication Type.

image

For Size, I have selected DS1_V2 Standard 1 Core 3.5GB RAM. I left out all the other default settings and created the virtual machine.

The overview of the Virtual Machine displays the IP Address, we need this IP Address to connect to the VM.

image

Once VM is created, download and install Putty SSH and Telnet client on your local environment. Run Putty Client and enter the VM IP Address as shown below and click Connect.

image

We will get an alert to cache the server’s host key. Click No.

image

Login to the console by providing the username and password (which we provided at the time of VM creation).

image

Now lets install Docker on VM. First lets become root on VM.

sudo –s

image

Install Docker using following command.

apt-get install -y docker.io

image

Start the Docker service and also configure it to start on system boot.

systemctl start docker

systemctl enable docker

image

Now check Docker version using following command.

docker version

image

Lets pull the Docker Image which we created as part of Create and Deploy Docker Container of ASP.Net Core 1.0 Application to Azure Linux Web Application.

docker pull ramiramilu/dockerdotnetcoreapp

image

To check if Docker image is downloaded, execute below command.

docker images

image

Run the downloaded Docker image using following command.

docker run -p 8000:5000 ramiramilu/dockerdotnetcoreapp

image

Finally we need to add an inbound rule to allow traffic on 8000 port. Find the Network Security Group.

image

Click on the Network Security Group, Select Inbound Security Rules. click Add to add a new Inbound Rule.

image

Add 8000 port rule as shown below and click ok.

image

Navigate to the IPAddress:8000, we should see our application up and running.

image

So we finally made our ASP.Net Core 1.0 application up and running on Azure Ubuntu Virtual Machine using Docker Containers.

That’s it for now. Happy Coding and Stay Tuned!!!

You may also like...