Exercise 2 – installing the Azure CLI
In this section, you’ll learn how to install the Azure CLI.
The following steps must be carried out on the OS of a machine you have admin access to; this could be physical or virtual. We are using a Windows 10 device for this exercise – Windows 10 Pro 20H2 using PowerShell 7 for reference. Once installed, the CLI can be accessed via PowerShell or the Windows Command Prompt (CMD):
- From your device, search for Windows PowerShell 7 and click Open.
Enter the following command:
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList ‘/I AzureCLI.msi /quiet’; rm .\AzureCLI.msi
The following screenshot shows the installation progress:
Figure 6.20 – Installing the Azure CLI via PowerShell
2. Close PowerShell and reopen it, Then, enter the following command to run the CLI from PowerShell:
az login
3. When the pop-up Azure sign-in page appears, as shown in the following screenshot, sign in:
Figure 6.21 – Azure Sign in page
4. Enter the following command to check the version of the CLI that’s been installed:
az version
The output will look as follows:
Figure 6.22 – CLI version
5. Enter the following command to update to the latest version:
az upgrade
6. The output will look as follows:
Figure 6.23 – CLI upgrade
7. The command’s output in the preceding screenshot shows that the latest updates have been installed and that no is upgrade available; this final command concludes this exercise.
We looked at installing the Azure CLI in this exercise. In the following exercise, we will create a resource group and a virtual machine using PowerShell from Cloud Shell.