Step-by-Step Guide On how to Create a Virtual Machine on Azure Portal.

What is CLI?

CLI stands for “Command-Line Interface” It is a text-based interface that allows users to interact with a computer program or operating system by typing in commands. The commands are typically composed of specific keywords, options, and parameters that control various functions and tasks of the program or system.

In the context of cloud computing and services like Microsoft Azure, the Azure Command-Line Interface (Azure CLI) is a tool that enables users to manage and interact with their Azure resources and services through the command line. It provides an alternative to using graphical user interfaces (GUIs) by allowing users to perform tasks, automate processes, and manage resources using a series of commands entered into a command-line terminal.


Step 1: Install the Azure CLI

If you haven't already, start by installing the Azure CLI on your local machine. You can download and install it from the official Microsoft Azure CLI website.
Here is the link : https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows
Install the exact specification for your operating system we have for windows (32 or 64 bits) mac os and linux.

Step 2: Log in to Azure
Open your Power Shell and run the following command to log in to your Azure account: Az Version to confirm if the CLI is installed then Az login

*From here you will be redirected to to a web page to login your Azure Account.
*Select the account

3. You will get the notification below, close the page and go back to powershell.

4. You are now logged in in your Power shell it will display your Azure account details.

Step 3. Create a Resourse group -Create a new or select an existing resource group where your VM will be deployed
-In put the following command.
az group create --name <ResourceGroup Name> --location <input the Azure location you want your resource to be> and press enter.
Weldone the resource group has been successfully created..

Step 4: Create a Virtual Machine:
-
Input the following command
az vm create --resource-group AugustRG--name uzorlinux--image UbuntuLTS --admin-username brendan --generate-ssh-key

--resource-group: Here we add the Resource group we created earlier on {AugustRG}

--name: Provide a name for your VM. Here I named it uzorlinux

--image: Choose the VM image or the Operating system you want to use (e.g., UbuntuLTS, WindowsServer).Since we are creating a linux Vm I choose UbuntuLTS.

--admin-username: Here is brendan
--admin-password: Set the credentials for accessing the VM, Since we are creating a Linux vm here am going to use --generate-ssh-key.

- Once all the above command line has been properly inputed hit enter, your virtual machine will start running as shown below.

Note: The part of the command line annotated with arrow returned negative (in red) because on the first command I used “Brendan” as my “adim user name” which contained an upper case “B”.Hence it returned “admin user name cannot contain upper case character A-Z, special characters \/"[]:|<>+=;,?\@#()! or start with $ or -”
*Another mistake which is the second arrow I omitted “az” at the beginning of the command hence, it returned negative.

-You can now go to your Azure portal to view the VM you just created using CLI.

Step 5: Login using SSH
-To login to your linux Vm using SSH you can run the following command on CLI:
ssh <admin-username>@IPaddress
-To coppy the Ipaddress on Azure portal click on connect and copy the Ipaddress

-Lastly I will go to CLI and run the following command;
*ssh brendan@13.87.86.68

  • Congratulation we have successfully created a Linux VM and loggin with SSH. Thank you for reading I hope this was helpful.