DEV Community

Cover image for How to create a Virtual Machine and Resource Group using Azure Command-line Interface
Adisa Oluwaseyi
Adisa Oluwaseyi

Posted on • Updated on

How to create a Virtual Machine and Resource Group using Azure Command-line Interface

The Azure Command-line Interface is a cross-platform open source command-line tool that we may use to build and manage resources in the Azure portal.

This application allows us to issue commands and manage Azure resources directly from the Windows command prompt. Since this application is cross-platform users can easily install it on windows, linux or macOS.

It is nearly identical to Azure Powershell in capability and function.

In this guide we will be using Azure CLI to create a resource group and virtual machine, execute commands in the cloud shell.

Creating Resource Group and Virtual Machine with Azure CLI

Step 1:
Visit portal.azure.com, login or sign up if you don't have an account, you can get a free account at azure.microsoft.com/en-us/free/

Step 2:
On the Azure portal page click the icon on the top right corner, then select bash

Image description

Step 3:
Click confirm to switch to bash

Image description

Step 4:
To create a resource group paste these codes into your Azure CLI:

az group create --name mycoolRg --location EastUS
Enter fullscreen mode Exit fullscreen mode

Image description

Step 5:
To create a Virtual Machine paste these codes into your Azure CLI:

az vm create \
--resource-group mycoolRg \
--name myVMcli \
--image UbuntuLTS \
--generate-ssh-keys
Enter fullscreen mode Exit fullscreen mode

in the code above i used mycoolRg and myVMcli as my resource group name and my virtual machine name respectively, you can use any name of your choice

Image description

Confirming the Resource group and Virtual Machine created

Step 1:
Go to Azure portal page and search for resource group and click it

Image description

Step 2:
Here is the resource group created, click it

Image description

Step 3:
As you can see here is the Virtual Machine we created with Azure CLI

Image description

Thank you for reading!!! 🙏

Top comments (1)

Collapse
 
yemmyoye profile image
Yemisi Oyesainu

good