In this article, I will be creating a Linux VM (virtual machine) using the Azure cli I will be using cli commands in the Azure cloud shell.
The first thing is to open the Azure Cloud shell, as shown in the diagram below.
CLI stands for the command-line interface. It is a text-based interface that allows you to interact with a computer or operating system by typing commands.
is the cloud shell icon but
We don't have any file storage yet in my account, so by clicking on create storage, it would create one for me.
As indicated in the diagram below the file storage is now created and ready to use, and 2. I am using the bash shell.
Note: A bash shell is a command-line interpreter that is used to interact with the operating system. It is a text-based interface that allows you to type commands and execute them. Bash is the default shell on most Linux distributions and macOS.
You could type in the command "az help" and it would throw all the possibilities at you as shown below
To check for the current version of az I am using the type "az version" but I want mine to be in table format and not in the default JSON format, so I used "-o table" where -o is short for output.
where 1. is in JSON format and 2. is in table format. As shown in the diagram below.
In the diagram below, I used the command (cmd) to demonstrate "az group" as an example of how to get syntax help and list the resource groups that are available in my account. Where 1. is "az group" then I used the tab key for auto-complete, and 5. is to list the resource groups in a table format.
Here are the available resource groups in the Azure portal below, just as they are in the diagram above.
In the diagram below, I created a new resource group. The syntax for creating is in the diagram below 1. I then listed the resource groups in Account 2.
In the diagram, I created a Linux VM The syntax "az vm create" denotes creating a VM, and the others, like "--resource-group" are parameters that I used to distinguish my VM, e.g., "--name linuxvm" as shown in the diagram below.
After entering the command, you will wait until the prompt returns, as shown in the diagram below.
In the diagram below, you will see that the VM is running, and I Listed the number of VMs available in my resource group, reggieweek3project.
Shown in the diagram below.
Here in the diagram below, I have to extend the idle timeout to avoid being disconnected after the default timeout of 4 minutes. So I clicked on the public IP
Then I dragged the radio button and saved it. As indicated in the diagram below.
In the diagram below, I connected to it using the username and password I created from my local computer, where I have already installed Azure cli, as shown in the diagram below.
To install Azure cli on your local computer, click on Azure cli where 1. is to see how many resource groups are available in my account, 2. is to ssh remotely into my Linux VM and 3. is to accept the connection as it is my first time connecting to the Linux VM, This 3. only happens the first time.
Another location to get the cli commands for the VM
In the diagram below, I entered the command "az vm" and then the tab key gave me all the possible actions that "az vm" can perform. And the command "az vm show --resource-group regggieweek3project --name linuxvm --show-details" returned the results in JSON format.
In the diagram below I requested that the command "az vm show --resource-group regggieweek3project --name linuxvm --show-details" return the results in table format.
In the diagram below, I entered the command to stop the VM and the command to show that the VM is stopped.
Also, you can see it in the Azure portal below.
Here is another command to show both the private and public IP addresses associated with the VM.
Additional commands are shown below.
Now I am done, and I want to clean the resources, beginning with deleting the resource group to incur no cost.
Evidence that the command is working
The resource group reggieweek3project is no longer there
Now, from my local computer, I use the Power shell to delete the resource group that Azure created for me to use the Cloud shell
Note: I had earlier installed the Azure cli on my local PC.
Now we are back to how we started as shown in the diagram below.
You can check the Microsoft website for additional details https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-manage
If you find this article useful pls like, share, and follow me.