DEV Community

Emmanuel Oluajo
Emmanuel Oluajo

Posted on

1

CREATING A VIRTUAL MACHINE USING AZURE CLI

We already established that there are several routes that can be taken to achieve the deployment of resources and services on Azure.
For today, I will be using the Azure Command Line Interface (CLI) to create a virtual machine on Azure.

PREREQUISITE

  • Working computer
  • Internet connection
  • Microsoft Azure account + active subscription
  • PowerShell application

PROCEDURE

INSTALL AZURE CLI

Regardless of which OS runs on your computer, click on this link (https://learn.microsoft.com/en-us/cli/azure/) to get guidelines on how to set up Azure CLI on your computer.

CONNECT TO AZURE ACCOUNT

To achieve this, type in this command az login in the command line interface.
You either have a sign-in webpage or a sign-in pop-up window appearing on your screen after entering that command.
Select the Azure account you want to log in with and click on “Continue” as shown below.

Image description

A list of available subscriptions you have and their respective IDs will be generated.

Image description

Select the one you require following the onscreen instruction.

Image description

CREATE A RESOURCE GROUP

Create a resource group by entering a command in the interface following the format below:
az group create --name **resourcegroupname** --location **regionname**
NB: The asterisked sections are to be customised to suit your requirements.
A message informing users of the success will be displayed on the following lines.

Image description

The newly created resource group can also be located on the Azure portal for further verification.

Image description

CREATE A VIRTUAL MACHINE

In a manner similar to how a resource group was created, a virtual machine can also be created but in this case, providing more specifications as we would on the Azure portal when creating a VM.
Enter a command in the CLI following the format below:
az vm create --resource-group **resourcegroupname** --name **vmname** --image operatingsystemname --admin-username username --admin-password '**password0!**' --size **vmsize** --subnet **subnetname** --vnet-name **vnetname** --nsg **nsgname** --no-wait
NB: The asterisked sections are to be customised to suit your requirements.

Image description

The created VM can be located on the Azure portal for further verification.
Open the VM resource on the portal.

Image description

On the VM page, click on “Settings” and then, “Advisor recommendations” to see if the VM and other resources are not running at optimal states.

Image description

Image description

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay