There are different ways of creating virtual machine. These include azure portal, PowerShell , Azure Resources Manager template and the Azure Command-Line Interface (CLI).In our previous blog posts, we discussed the first three methods, and we will now cover the last one, CLI, in this blog.
CLI is a cross-platform command-line tool that allows users to login to Azure and run administrative commands on its resources. It enables the use of interactive command-line prompts or scripts to execute commands through a terminal.
There are two ways to access CLI and they are
(i)from a browser through the Azure CloudShell
(ii)from inside a Docker Container
Let's proceed to our task of the day
1.Log in to Azure portal and click on CloudShell
Select Bash
2.Copy the Command for creating your Resource group and paste it on the terminal window. Here I will create a resource group with the name AbbyRg using this command:
az group create --name AbbyRg --location EastUS
From the image above, the Provisioning state is showing succeeded indicating that the Resource group, AbbyRg has been created
3.Copy the Command for creating your Virtual machine and paste it on the terminal window.I will name my Virtual machine AbbyVMcli and use the command below:
az vm create \
--resource-group AbbyRg \
--name AbbyVMcli \
--image UbuntuLTS \
--generate-ssh-keys
Then press enter
The Powerstate in the image above shows that the Virtual machine is running indicating that it has been created
4.To confirm the status about the Resource group and Virtual machine created, go to your azure account and search for the two.The images below show the Resource group AbbyRg and Virtual machine AbbyVMcli on the Azure portal
5.For compliance with Azure best practices, we will check Azure Advisor for recommendations in respect of reliability, security, operational excellence, performance, and cost of the resources created.
Click on the Hamburger Icon on the top left-hand corner of Azure portal and Select Advisor from the dropdown menu
The image below shows a Recommendation on Reliability. The recommendation is to use NAT gateway for Outbound Connectivity
I hope you find this blog post useful.
Top comments (0)