So in this article, we’ll learn the following things:
- What is a Virtual Machine?
- Why we use Virtual Machines?
- How to create a Virtual Machine?
- How to use a Virtual Machine in your Computer System?
- Microsoft Azure Subscription
- Good Internet Connection
So let’s start with the first question.
What is a Virtual Machine?
In simple words, If we use a Computer machine over the internet which has its own infrastructure i.e. RAM, ROM, CPU, OS and it acts pretty much like your real computer environment where you can install and run your Softwares. All you need is an internet connection to use that machine. We can increase and decrease the size of the disk, RAM, the capacity of CPU according to our needs.
At a time we can run multiple virtual machines in a single computer.
Why We Use Virtual Machines?
To answer this question let’s assume a scenario:
Ram is a freelancer and develops Computer Games. So once a client wants a game to be developed which should run on All of the operating Systems (i.e. Windows, macOS, Ubuntu).
On the other hand, Ram has only one PC which runs on macOS. So he needs Windows and Ubuntu to run and test his game.
Now here, Virtual Machines come as an option. So Ram can deploy two Virtual Machines for each of the Operating System and test his game. When the game is tested and the client is happy with it, Ram can delete both of the virtual machines.
So this was an example in terms of operating systems.
Let’s take another scenario:
In this case, the Client wants a high-end Game which requires a lot of computing power to be developed and Ram doesn’t have a computer with that much capacity So Ram has two options, first, he can purchase a new PC or upgrade his PC which can be end-up with high cost. The second option is creating a virtual machine with that much computing power.
So in the second example, The cost will be too lower than building a new PC. He can increase or decrease the computing power or memory any time he wants, at a lower cost than getting a new One.
So now you understand what is Virtual Machine, let’s see how to create one using Microsoft Azure.
How to Create a Virtual Machine in Azure?
To create a virtual machine go to Azure Portal.
It will look something like this:
So you can just click on Create a Resource button that will be on the front page or click on the menu button and select Create a Resource button from there as shown in the picture below:
After clicking on this button you’ll be redirected to the resources page from where you can either search a resource by its name or scroll down the menu to find out.
In our case, we want to create a virtual machine So we can search for Windows or Ubuntu but we here we can also see Both of these are available in the popular section also. So we can choose it from here too. So I am going to select the Windows Server 2016 Data Center to create a Windows Virtual Machine.
After this, you’ll be redirected to Create a Virtual Machine page.
So there are 7 different tabs where we’ll fill the details about the virtual machine we want to create. let’s have a look at each of it one by one.
So here you’ll see the details like:
- Subscription – So here you have to choose the subscription-like if you have a free subscription related to your email account then it will be shown up in the list or on the other hand if you have upgraded your plan you can select it too.
- Resource group – Here you have to choose a resource group where you want to store the resources related to your virtual machine. Basically resource groups are used to group the resources related to a project. you can think it as a folder containing resources so you can monitor it easily.
- Virtual Machine Name – you can choose any name you want but the name should be unique in your resource group.
- Region – There are various regions available in the Azure Portal. If you’re confused about what a region is – It is a group of data centers situated in an area and that area called a region and Azure gives more regions than any other cloud provider. There are various parameters, on based you can choose your region (but we’ll discuss this in another article) for now you can choose the region near to you for low latency.
- Availability options – Azure offers various options to manage the availability of our application by protecting data and make it available in maintenance or data center outages. To learn more about it – https://docs.microsoft.com/en-us/azure/virtual-machines/windows/availability
- Image – Here you can choose the operating system that you want to use in your virtual machine (i.e. Windows 10 pro, Ubuntu Server )
- Azure Spot Instance – To access the unused azure compute capacity at large discounts, you can choose yes. It will provide scalability as well as reduced costs. For more – https://azure.microsoft.com/en-in/pricing/spot/
- Size – Here you can choose the memory size (RAM) as well as CPUs according to your need. The approx prices will be also given in front of the memory options.
- Username & Password – This username and password will be required to use the virtual machine just like we use in our system.
- Inbound ports – Here we’re setting public inbound ports to “allow” and selecting RDP port. There are other options like HTTP, HTTPS, SSH, RDP. If you’re making a VM for webserver you can choose HTTP and HTTPS. SSH and RDP are for accessing your virtual machine remotely. For windows, I am choosing RDP (Remote Desktop Protocol) to access this virtual machine to access it from a windows machine.
Here you’ll see the options like:
- OS disk type – Here you can choose the external disks according to your need, you will be seeing options Premium SSD, Standard HDD, Standard SSD.
- Encryption type – Here you can encrypt the disk if you want. You can do it in two ways – 1. With a platform managed key, 2. A customer-managed key.
- Enable Ultra Disk compatibility – It is the same as above but with higher throughput, high input/output per second, and low latency.
- Data Disks – Here you can add additional disks for your VM and configure it and one thing to point out here that virtual machine also have its own temporary disk.
Here you’ll see options like:
- Virtual Network – your network will be logically isolated from other networks in Azure. Here you can configure IP address ranges, set rout tables, subnets. Overall you can imagine this like the network we have in our traditional data centers. So you can also access the other virtual machines in the same virtual network.
- Public IP – Here we can use a public IP address to communicate with the other virtual machines which aren’t in the same network.
- NIC network security group – It consists of the security rules that we want to apply on our network. For details – https://docs.microsoft.com/en-us/azure/virtual-network/security-overview
- Accelerated networking – You can turn this on for high throughput and low latency on our network.
- Load balancing – you can use this to distribute a load of incoming traffic on your virtual machine. Get more on https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-overview
Here you’ll see the options like:
- Boot diagnostics – you can turn on this to get the logs of the virtual machine running. It helps to solve the startup issues.
- OS guest diagnostics – You can turn this on to get the metrics per minute. It can be used to identify the performance of your virtual machine. For more – https://docs.microsoft.com/en-us/azure/virtual-machines/windows/monitor
- Diagnostics storage account – It is a storage account where your metrics will be written so we can also analyze them with other tools if we want.
- The system-assigned managed identity – So this is to manage your keys or password on azure key vaults and integrate this with our Virtual machine for better security. For more – https://docs.microsoft.com/en-us/azure/key-vault/general/tutorial-net-windows-virtual-machine
- Login with AAD credentials – If we turn this on then we can also access our virtual machine with the credentials of Azure Active Directory and we can also enforce Multi-Factor Authentication. If you want to learn more about azure active directory then please have a look on – https://azure.microsoft.com/en-in/services/active-directory/
- Auto Shutdown – You can set at what time you want to shutdown your Virtual Machine so you don’t have to pay an extra penny for computational power when you’re not using the virtual machine. I recommended you to turn this on.
- Backup – To protect our virtual machine from accidental deletion or corruption of disks, you can turn this on.
Here you’ll see options like:
- Extensions – Using this you can add new features to your virtual machine like Antiviruses, Configuration Management, Rapid7, Azure Network watcher. For more – https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/overvie
- Custom data – You can pass a script, file, or other data while our virtual machine is being deployed. For more details have a look – https://azure.microsoft.com/en-in/blog/custom-data-and-cloud-init-on-windows-azure/
- Host – You can have a dedicated host to your virtual machines or other resources related to one Azure subscription. To have a look in details – https://docs.microsoft.com/en-us/azure/virtual-machines/windows/dedicated-hosts
- Proximity Placement group – It is a logical grouping that is used to make sure that resources are located nearly to each other as much as possible. It is useful where we require low latency. For more – https://azure.microsoft.com/en-in/updates/proximity-placement-groups-are-now-available/
- VM generation – Here you will have two options Gen1 and Gen2. Where Gen1 supports most of the guest operating system but on the other hand, Gen2 supports mostly 64-bit version of Current versions of Linux and Windows as well as FreeBSD OS.
Note: Gen2 virtual machines do not support disk encryption yet.
Here you can categorize your resources together so you can see the details like billing information of all the related resources that have the same tag.
For example – You have some resources related to the development of a project so you can apply name as “Environment” and “Development” as value and you will be able to see the information on a category level instead of resource level. For in-depth – https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources
7. Review and Create
Here you’ll get the details like:
- Product details – In this section, you can see how much you’ll be charged for an hour and see the details that you have chosen in previous tabs to make sure it is right.
- Down a template for automation – Even you can download the template as a JSON file so if in future you need to make the same kind of virtual machine then you can create using this template instead of filling all of the information from starting.
Also, the validation of the information that you have filled earlier will happen in this tab only. So make sure everything is right and we are ready to deploy our virtual machine. Click on “Create” Button.
After clicking on create button you’ll be redirected to this page:
Which is showing “Your deployment is underway”. It will take 5 to 10 minutes to complete the deployment. After deployment, you’ll see something like this:
Congratulation you’ve created your first virtual machine.
Now click on “Go to resource “ to see more information.
How to Run Virtual Machine?
So after creating a virtual machine now the next point is how to access it from any remote machine. It is pretty simple. Let’s see how.
Remember, the inbound ports (RDP) we have selected while creating a virtual machine. Now we’ll use that RDP (Remote Desktop Protocol) to connect to our virtual machine.
As mentioned in the above screenshot, if we click on “Go to resource” you’ll be seeing this screen.
Click on the “Connect” button on the top left corner.
Click on “Download RDP File “ and open that downloaded file.
Click on Connect button.
Enter the Username and Password that we have created while creating the virtual machine.
Finally, We’ve connected to our virtual machine. You can do almost anything that you do in your local machine and don’t forget to check the internet speed in your virtual machine, Its amazing. I tried to download PyCharm on my VM and it took 1 second to be downloaded.
If you’ve any suggestions or problems related to this article then please leave us a comment in the comment box below.
The post Azure Virtual Machine Tutorial appeared first on The Crazy Programmer.