
Hello readers !!! Hope you all are doing great . Today I am here with another new concept in which we’ll see that how we can create VM in Azure using Azure CLI . Firstly we will see what is azure and azure cli and carry on with the vnet and creation of it . So stick with me till end .
Let’s get Started
Introduction
What is Azure
Microsoft Azure is a platform that enables users to participate in agile cloud computing, designed to build and manage apps through Microsoft’s data centers.
Within the platform a variety of tools improve IT performance. By definition, Azure (formerly Windows Azure) is Microsoft’s operating system for cloud computing.
This operating system was commercially released just a few years ago on February 1, 2010. Designed to minimize running costs and simplify all IT management processes, it has a definite impact on the market.
What is Azure CLI
The Azure Command Line Interface (CLI) is a cross-platform command-line tool for connecting to Azure and running administrative commands on Azure resources. You can run commands from the terminal using an interactive command line prompt or scripting.
Vnet
An Azure Virtual Network (VNet) represents your own network in the cloud. This is a logical separation of Azure clouds dedicate to subscriptions.
You can use VNets to deploy and manage virtual private networks (VPNs) in Azure and optionally link VNets to other VNets in Azure or to your on-premises IT infrastructure to create hybrid or cross-premises solutions .
Each VNet you create has its own CIDR block and can be associate with other VNets and on-premises networks as long as the CIDR blocks do not overlap.
Prerequisites
- Install the azure CLI locally click here to install
- sign in to the Azure CLI by using the az login command .
Creating Vnet Using Azure CLI
Now , let’s see how we can create Vnet in azure using azure cli step-by-step :
STEP 1 Run command to login into azure by :
az login

STEP 2 Set subscription
Once you login into the azure account , you need to set subscription id . Use command :
az account set --subscription $subscriptionId
STEP 3 Create a Resource Group
First create a resource group to host the virtual network by running command:
az group create --name resource_group_name --location eastus

as you can see my resource group with the name test has been created .

STEP 4 Create Virtual Network
Create a default virtual network named myVnet with one subnet named mysubnet with a DDoS Protection plan enabled , by command:
az network vnet create --address-prefixes 10.0.0.0/16 --name MyVnet --
resource-group test --subnet-name MySubnet --subnet-prefixes 10.0.0.0/24

as you can see Myvnet in resource group test has been created using the above command in azure cli as :

STEP 5 Creating Virtual Machine (VM)
In this step we’ll create a virtual machine in the baove created vnet using cli . Use the below command to do so :
az vm create --resource-group test --name your_vm_name --image image_name --
vnet-name vnet_name --subnet subnet_name --generate-ssh-keys --output json --
verbose

as you can see I have created Virtual Machine using azure cli .

yes we are all set , so in this way we can simply create various resources in azure using azure cli .
Conclusion
So , In this blog we have seen how we can create vm in azure using azure cli and also about azure and vnet , and how we can create resource group , set subscription id along with vnet creation. Thankyou so much for your patient , I hope you have enjoyed and learnt something new .
Reference
HAPPY LEARNING!!!
Thank You!!!