A Guide to Use Azure CLI to create a Resource group and a VM
Published: 2023-06-10 14:23:48

**Azure Command Line Interface (CLI) as a cross-platform command-line tool to connect to Azure and execute administrative commands on Azure resources. It works on OS, like Windows, macOS, and Linux.
With the Azure CLI, one can quickly connect to Azure and perform tasks on your Azure resources. You can create any resources such as VMs and storage accounts. It’s flexible and efficient by allowing one to execute commands directly from your computer's command-line interface. 

**How to download and install Azure ClI on a VM created on Azure**
1.	First and foremost Download and install Azure CLI on your computer before one can use it, by following the instructions provided below https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
2.	Incase you want to install azure CLI on a VM that you have created on your Azure account, before using it to create Resource group and VM, please follow the steps below:

a.	RDP into you VM, enter you IP address, 
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7v2ov3ksaufuthssh0ck.png)


b.	then enter username and password
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ij7wfucnd29i4vilwnu1.png)


c.	When your desktop window launched, open the edge browser, enter the link below to download azure cli and install. https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
    
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hctwld9gofcttjoelzyy.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/avuf7th3w7hd8cw544b1.png)




d.	After installation open powershell as an admin and enter command az and press enter, you will see the pic below indicating that azure cli has been install
 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ba34ggdgdg80x5j69hmx.png)


e.	Log into your azure account by typing command az login, press enter, you will be redirected to a web browser to log into your azure account. Enter your account Username and password, 
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rh9hra9kuxvp05gw08v2.png)


after you logged in, you will receive a web page as below
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6gz46t2scsatybvjkipj.png)


On the powershell you will receive a message: “Welcome!! you are logged in, showing your subscription and your account name.
 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1nlxa3g9xl3r7spykcln.png)


Note: After successful installation of azure cli, you can start creating your resource group and the VM

**Create Your Resource Group**
Input the command “**az group create --name** (name your resource) **--location** (input the location you want your resource to be), and press enter.
e.g. resource name as jesseresource and location as northeurope
           

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lafy639cdmd7ohd7isu4.png)




**Create Your Virtual Machine**
a.	Input the command: “**az vm create --resource-group** (input your resource group name) **--name** (name your virtual machine) **--image** (the name of the image you wish to use) **--admin-user** (the admin name) **--generate-ssh-key**. Then press enter, the VM will start running as below
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jvoo1epmzq1m5hfwcwd6.png)


b.	When you check your Azure portal, you can see the VM will all details as created using Azure CLI.
 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9lyacj9mc1eluhy6mnn.png)



With the above steps one can create resource group and VM, Practice makes perfect. Thanks

**