A virtual machine is an important element of most successful businesses using cloud resources.
Think of a virtual machine as a personal computer with your desired specifications to run different tasks for you. For instance, you need a PC with at least 32GB RAM and over 1TB storage among other specifications. But due to limited financial capabilities, you are unable to purchase the PC. This is one of the ways a virtual machine comes in.
In this article, I will show you five (5) different ways to create virtual machine in Microsoft Azure.
Microsoft Azure is one of the foremost cloud services provider with high credibility. Before you access the Azure portal, you need to sign up for an account - a free tier account is also available with enough resources to get started including a $200 credit.
Now to the real business. How can you create a virtual machine in Microsoft Azure?
Option 1: Using the Azure Portal
Access the Azure Portal by visiting https://portal.azure.com. Input Virtual Machine in the search bar.
In the search results, click "create" on the Virtual Machine icon
Select your subscription. If you do not have an active subscription, create one or a free trial subscription from Microsoft.
After selecting your subscription, select the resource group this virtual machine should belong to or create a new resource group
Give your virtual machine a name - like a computer name. Select an OS (image) for your VM.
After selecting your image and check other information, click on "review + create" to create your virtual machine.
Deployment will take a moment. After deployment completes, you have successfully created a virtual machine and can go to the resource.
Option 2: Using Custom Template from Azure Quickstart
Creating a virtual machine by deploying using a custom template is a fast and easy method that does not require a user to do too much.
Select "Deploy custom template"
On the next page, provide your virtual machine details including an admin username and password.
Click on "Review + create" and watch the magic!
Option 3: Using Azure Cloud Shell
Azure Cloud Shell provides us with a simple way to create resource group and virtual machines using simple shell commands.
Open up the cloud shell terminal by clicking on the icon on the azure portal.
Select PowerShell in the presented tab.
Ensure you are in the right directory. In the image below, we are in the "/home/seidu" directory.
Before crating a virtual machine, there must be a resource group. The following commands should be run in this form: New-AzResourceGroup -Name "Your Resource Group Name" -Location "Your resource location".
Example:
New-AzResourceGroup -Name "myresourcegroup" -Location "EAST US"
After successfully creating a resource group, we will go ahead to create our virtual machine using this command:
New-AzVM -ResourceGroupName "Resource group name" -Name "vm name" -Location "EAST US"
Example:
New-AzVM -ResourceGroupName "myresourcegroup" -Name MyVm -Location "EAST US"
You will be prompted to provide a username and password for the virtual machine. Virtual machine will then be created and details displayed as in the image below.
Option 4: Using Azure Cli
The microsoft azure CLI command is similar to using the power shell commands.
To access the CLI, click on the "BASH" terminal in the cloud shell window.
To create a resource group, run:
az group create --name "resource group name" --location "Resource Location"
Example:
az group create --name mytestgroup --location EastUS
To create a virtual machine in our resource group, we run:
az vm create \
--resource-group "resource group name" \
--name "vm machine name" \
--image "os image" \
--generate-ssh-keys
Exmple:
az vm create \
--resource-group myRgGroup \
--name myVmMachine \
--image UbuntuLTS \
--generate-ssh-keys
Conclusion:
Virtual machines are essential for today's businesses as it helps to scale in/out up/down depending on the needs. Microsoft Azure has done so well in this regards by providing developers with all they need.
Important Notice: Remember to delete any resource you create which is not in use in order not to incur unwanted expenses.
Top comments (0)