Open In App

Microsoft Azure – Install Azure Command Line Interface (Azure CLI)

Last Updated : 22 Nov, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Azure CLI is a very powerful tool that can be used to automate tasks, create, update, manage or delete azure resources or to troubleshoot problems with az module cmdlets. By installing az modules on your system or on your development system you and your development team can easily create, update or manage Azure AD and Azure resources such as management groups, subscriptions, resource groups, virtual machines, virtual networks, storage accounts, web apps or any other Azure native services directly from the command line interface.

If you are looking for a powerful and easy-to-use way to manage Azure resources, then you must definitely learn and make use of this Azure CLI command line tool to simplify the management across Azure services.

Requirements

  • One should have administrator privileges on Windows System to install Azure CLI.
  • The Azure CLI installer requires .NET Framework 4.7.2 or later.

Steps for Installing Azure CLI

Step 1: To install the Azure Command Line Interface (Azure CLI) we have to open Windows PowerShell from your system and select Run as Administrator. To Know the commands in Azure CLI to maintain the VMS refer to the Microsoft Azure – Azure CLI Commands to Manage Azure VMs.

Windows Power shell

Step 2: Now, we have to create a new PowerShell file to do that use the cmdlet New-Item <file name>.ps1

Syntax:

New-Item <file name>.ps1

Example:

New-Item installAzCLI.ps1

create new power shell file

Step 3: Once you are done creating a new PowerShell file. Use the code cmdlet to add the script into the file. Check syntax and example.

Syntax:

Code .\<file name>.ps1

Example:

Code .\installAzCLI.ps1

Check the sytank of file

Step 4: Now in the editor copy and paste the below following code to your PowerShell file <file name>.ps1 and use CTRL+S to save the changes.

$ProgressPreference = 'SilentlyContinue'; 
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi;
Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet';
rm .\AzureCLI.msi

Add code to the file

Step 5: In step 4 we have saved the Azure CLI installation script. Now, to execute or run the PowerShell script use the following syntax structure .\<file name>.ps1

Syntax:

.\<file name>.ps1

Example:

.\installAzCLI.ps1

Run The script to install

Wait until the installation is complete. (It might take 2-3 minutes to install az cli modules)

Installing progress

Verify Azure CLI Installation

Once the installation is complete, you can verify the installation was successful or not by by just typing the command az or az -h:

az

This az command will list the available Azure CLI commands.

az -h

This will also list the available Azure CLI commands. Check out the sample output for better understanding.

Sample Output:

Verify the installation

If you wish to check the Azure CLI then you may check the version of Az CLI on your system by running this below command:

az version





This will list the versions of azure cli, azure cli core, azure cli telemetry and extensions version if any.

Sample Output:

Check the version

To build your own CLI extension refer to Microsoft Azure – Building Your Own Azure CLI Extensions.

Clean Up or Uninstall Azure CLI from your Environment:

On your Desktop Click on Windows Start button > Go to Settings > select Apps >> select Apps & Features >> Search for Azure CLI >> Select Azure CLI service >> Click on Uninstall to continue the removal of Azure CLI.

Removal will take around 5-10 minutes. Wait until it’s done and verify the removal of Azure CLI.

Uninstall-AzureCLI

Verify Uninstallation of Azure CLI

Open Azure PowerShell or Command Prompt and type “az –version.” If you are not getting any preview of Azure CLI, then you have successfully removed Azure CLI from your environment.

Sample Output before and after the removal of Azure CLI:

Remove-Azure-CLI-Sample-Output

FAQs On Azure Command Line Interface (Azure CLI)

1. In What Ways Can We Use Azure CLI?

Azure CLI is azure resource manage tool that can we used Interactively or in scripting to automate tasks.

2. Can We Deploy Azure Resources Using Azure CLI?

Microsoft has developed Azure CLI mainly to simply the task of azure resource creations, modifications, updates, and deletions with just a few commands or automate scripts.You configure Azure SQL using CLI refer to Microsoft Azure – Configure Azure SQL with Azure CLI.

3.Does Azure CLI As Azure PowerShell?

Yes, functions and packages are same. The only difference is Azure CLI can easily use for all type of Linux Servers. Where as Azure PowerShell can also be used but it is mostly used for Windows OS.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads