DEV Community

joseph4real
joseph4real

Posted on

A Guide to Use Azure CLI to create a Resource group and a VM

**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

b. then enter username and password

Image description

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

Image description

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

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

after you logged in, you will receive a web page as below

Image description

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

Image description

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

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

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

Image description

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

**

Top comments (0)