Deploying VM And Container In Azure

About this article

 
This article will tell you the basic and foremost concepts of Virtual Machines and Containers and how we can create them in the Azure Cloud environment. You’ll learn more about cloud computing and Azure in my coming articles. So, stay tuned for the next articles.
 
The topics to be covered are,
  • Introduction to Virtual Machines
  • The architecture of Virtual Machines
  • What is Azure VMs
  • Create a Virtual machine using Azure Portal
  • Deploying VM to a server
  • Differentiation between VMs and Containers
  • What is Docker Container
  • What is ACI in Azure
  • Deploying Docker to ACI

Introduction and background

 
In this article, you will learn about creating virtual machines in an Azure cloud environment. First, we’ll look at what a virtual machine is and then how can we create it using the Azure portal.
 
Virtual Machines are the software emulation of physical computers. All the computing resources like storage, networking, memory, processors are included in it. It includes separate operating systems that allow us to create our own application software it specific to the virtual machine’s responsibility. Anyone can access the virtual machine using the proper credentials given by an administrator. In other words, you can control and manage the virtual machine using a remote desktop client. Let’s discuss the complete architecture of the virtual machine so that we can understand how it builds and works.
 

Architecture of Virtual Machine

 
As we know, VM is an abstraction upon hardware that creates multiple instances of a single machine. It is done by the hypervisor whose responsibility is to run multiple VMs on a single machine. And each newly created virtual machine will contain an operating system, the application, and its dependencies. Let’s see this concept in a graphical view.
 
Deploying VM And Container Using Azure Cloud Environment 
 
Here, you can see the hypervisor is installed upon infrastructure. Let’s understand what hypervisor and infrastructure mean. For this, see the image below which is self-explanatory.
 
Deploying VM And Container Using Azure Cloud Environment 
 
You can see our main operating system is installed on our main physical hardware and then we use VMM to make more instances of this machine.
 

What is VMM?

 
This is the software that allows us to create more instances of the machine referred to as virtual machines and then allow us to manage and configure the virtual machines. VMM is also called hypervisor as depicted in the above image.
 
Hence you’ve seen that what the architecture of the virtual machine environment is. Now let’s understand how we can face it in the Azure environment.
 

What are Azure VMs?

 
Azure VMs allows us to create, use and manage virtual machines on the cloud. You can physically access the VM and have proper full control over VM. It will really help you when you want to do the customer configuration of software for any specific task. Now, let’s create a virtual machine in the Azure Cloud environment.
 

Create a Virtual machine using Azure Portal

 
In this section, we will create the virtual machine, make it available on the webserver, and then access it using the internet. Before creating a virtual machine on the Azure cloud, make sure to have the Azure subscription. Otherwise, create your Azure free account today.
 
Let’s create a virtual machine in the Azure cloud. Following are the steps.
  • Create a resource
  • Search “Windows Server 2016 Remote Desktop Session Host 2016” in the search bar.
  • Select the option “Windows Server 2016 Remote Desktop Session Host 2016”.
  • Then, simply create it.
Deploying VM And Container Using Azure Cloud Environment 
 
After clicking on the “Create” button, you’ll be redirected to the window where you can create the virtual machine as shown below.
 
Deploying VM And Container Using Azure Cloud Environment
 
Here you can create the virtual machine, in the project details section, select your subscription and give the name of the resource group or create a new resource group if it does not exist. I am giving the name “TestVMGroup” as shown below.
 
Deploying VM And Container Using Azure Cloud Environment
 
Under the Instance Details tab, select the following options (it may vary according to your desired scenario).
 
Deploying VM And Container Using Azure Cloud Environment
 
Then, make sure to give and remember your administrator details.
 
Deploying VM And Container Using Azure Cloud Environment
 
In inbound port rules, make sure to select the following options.
 
Deploying VM And Container Using Azure Cloud Environment
 
In “Nest: Disks >” you can select the Disk Options and create Data disks or attach existing data disks. Azure VMs also contains temporary disks. Here we will use “Premium Disk” which is recommended and click on “Nest: Networking >”.
 
In the Networking tab, you can see, Azure VM automatically creates a virtual network for you and defined its subnet and public IP.
 
In the Management tab, select the following options.
 
Deploying VM And Container Using Azure Cloud Environment
 
The advanced tab is for additional configurations which we don’t need here. So let’s skip tags and go to create a tab. Here, you will see all the configured details of your virtual machine, and then you can simply click on "Create" to create it.
 
Once your VM is configured then select your VM from your resource group and click on “Connect”.
 
Deploying VM And Container Using Azure Cloud Environment
 
When you click on “Connect”, you will be redirected to the following dialog box.
 
Deploying VM And Container Using Azure Cloud Environment
 
Then, simply download the RDP file and run it. After downloading it, simply open it and connect it. Then, give the credentials like username and password.
 
Deploying VM And Container Using Azure Cloud Environment
 
Then, give credentials and connect to VM. You can give username as .\azureuser or your original created username as mine Usman Ikram.
 
Deploying VM And Container Using Azure Cloud Environment
 
Then, simply click on “yes” to accept the security certificate and you will be redirected to the VM homepage. Congrats! You have deployed and connected a Windows Server Virtual Machine in Azure. Now let’s deploy it to a server.
 

Deploying VM to a server

 
For this go to the virtual machine and then run the "Windows PowerShell” as administrator. Then write the depicted command in PowerShell.
 
Deploying VM And Container Using Azure Cloud Environment
 
Then to install the webserver, run the following command.
 
Deploying VM And Container Using Azure Cloud Environment
 
When you got the status of success as true as follows,
 
Deploying VM And Container Using Azure Cloud Environment
 
Then simply close your RDP connection and go back to your Azure portal. And select the VM and then copy the IP address of the VM.
 
Deploying VM And Container Using Azure Cloud Environment
 
Then paste it into the web browser. You will see the following window.
 
Deploying VM And Container Using Azure Cloud Environment
 
Now let’s give the Domain Name to the public IP address. So again go to the overview of VM. And then, select the “configure” option under the tab DNS name.
 
Deploying VM And Container Using Azure Cloud Environment
 
Then give the valid name for your public IP address. See the image below,
 
Deploying VM And Container Using Azure Cloud Environment
 
Now you can see the DNS name for my IP address of the virtual machine.
 
Deploying VM And Container Using Azure Cloud Environment
 
When you run this, it will give the same output as follows,
 
Deploying VM And Container Using Azure Cloud Environment
 
Congratulations! You have created a web server that can be connected to publicly via this IP address, or via the fully qualified domain name.
 

The difference between Virtual Machines with Containers

 
Let’s understand the containers first. The container is the unit of software in which we package up the code and other dependencies of the application to make the application cross-platform and be able to run on multiple computing environments. Multiple containers can run on the same machine. Containers contain less memory than VMs (in some MBs) and can handle more applications. Containers virtualize the operating systems instead of hardware like VMs.
 
On the other hand, VMs turns one machine into many machines using Virtual Machine Monitor or hypervisor. Hypervisor allows multiple VMs to run on a single machine. As we know, VM contains the complete OS, code, application, and its dependencies or libraries which makes its size bigger (in GBs). Ultimately VM becomes slow.
 
Hence you have seen the difference between the VM and a Container. In short, VM virtualizes the hardware and Container virtualizes the operating system which makes it efficient.
 

What is Docker Container?

 
A platform for developers and sysadmins to develop, deploy and run the applications using containers. The use of Linux to deploy the containers is called containerization. Using Docker containers, we can create separate containers for a separate component of the application.
 
The portability of the container makes applications very easy to deploy in different environments. You can see the concept of containerized applications using the following image.
 
Deploying VM And Container Using Azure Cloud Environment
 
Azure supports Docker containers and multiple ways to utilize Docker containers and other types of Microsoft-based containers. Let’s understand what are Azure Container Instances?
 

Azure Container Instances

 
Azure container instances allow us to run containers without using any third party services or without managing any kind of virtual machines. So it provides us a platform as a service that allows us to upload our containers and then run them.
 

Deploying Docker to ACI

 
Here you will create, configure and deploy the Docker container into the Azure Container Instances in the Azure portal. Here we’ll use the image for a container called microsoft/aci-helloworld. Image contains a small web application written in Node.js and contains a static HTML page. Let’s create a container instance. For this, go to “Create a resource” and then under “Containers” marketplace select the “Container Instances” as follows,
 
Deploying VM And Container Using Azure Cloud Environment
 
Then configure the following settings on the container like name, region, resource group, image, name, pricing tier, operating system type.
 
Deploying VM And Container Using Azure Cloud Environment
 
Then give the DNS name of the container where you and the public can access the containerized application easily.
 
Deploying VM And Container Using Azure Cloud Environment
 
Then simply review and create the container. When your deployment is done successfully then simply open the container. And select the fully qualified domain name (FQDN) or IP address and paste it into the browser. See the image below,
 
Deploying VM And Container Using Azure Cloud Environment
 
When you run it in the browser then you will see the following window,
 
Deploying VM And Container Using Azure Cloud Environment
 
Hence, you have deployed an application to a container in Azure Container Instances (ACI).
 

Conclusion

 
Congrats! You have created, configured, and deployed the VM using Azure portal and Containerized application in ACI. Stay tuned for my next articles. Feel free to give your feedback.


Similar Articles