Install the Azure CLI
Quickly install the Azure Command-Line Interface (Azure CLI) to use a set of open-source shell-based commands for creating and managing resources in Microsoft Azure. Use one of the provided installer packages to install the Azure CLI on your operating system, install the CLI using Node.js and npm, or install the Azure CLI as a container in a Docker host. For more options and background, see the project repository on GitHub.
Once the Azure CLI has been installed, you will be able to connect it with your Azure subscription and run the azure commands from your command-line interface (Bash, Terminal, Command prompt, and so on) to work with your Azure resources.
The following installer packages are available:
Alternatively, if Node.js is already installed on your system, use the following command to install the Azure CLI:
npm install azure-cli -g
Install Node.js and npm on Linux distributions that use dpkg package management
The most common of these distributions use either the advanced packaging tool (apt) or other tools based on the
.deb package format. Some examples are Ubuntu and Debian.
Most of the more recent of these distributions require installing nodejs-legacy in order to get a properly configured npm tool to install the Azure CLI. The following code shows the commands that install npm properly on Ubuntu 14.04.
sudo apt-get install nodejs-legacy sudo apt-get install npm sudo npm install -g azure-cli
Some of the older distributions, such as Ubuntu 12.04, require installing the current binary distribution of Node.js. The following code shows how to do that by installing and using curl.
The commands are taken from the installation instructions found here. However, when using sudo as a pipe target, you should always check the scripts that you are installing and validate that they do exactly what you expect before running them through sudo. With great power comes great responsibility.
sudo apt-get install curl curl -sL https://deb.nodesource.com/setup | sudo bash - sudo apt-get install -y nodejs sudo npm install -g azure-cli
Install Node.js and npm on Linux distributions that use rpm package management
Installing Node.js on RPM-based distributions requires enabling the EPEL repository. The following code shows the best practices for installation on CentOS 7. (Note that in the first line below, the '-' (hyphen) is important!)
su - yum update [enter] yum upgrade –y [enter] yum install epel-release [enter] yum install nodejs [enter] yum install npm [enter] npm install -g azure-cli [enter]
You can install Node.js and npm on Windows and OS X using the installers from Nodejs.org. You might need to restart the computer to complete the installation. Check if node and npm were installed properly by opening a Command or Terminal window and typing
If it shows the version of the npm installed, you can go ahead and install the Azure CLI with
npm install -g azure-cli
At the end of the installation, you should see something similar to the following:
firstname.lastname@example.org ..\node_modules\azure-cli |-- email@example.com |-- firstname.lastname@example.org |-- email@example.com |-- firstname.lastname@example.org |-- email@example.com |-- firstname.lastname@example.org |-- email@example.com |-- firstname.lastname@example.org |-- email@example.com |-- firstname.lastname@example.org |-- email@example.com (firstname.lastname@example.org) |-- email@example.com (firstname.lastname@example.org) |-- email@example.com |-- firstname.lastname@example.org (email@example.com, firstname.lastname@example.org, email@example.com, firstname.lastname@example.org, email@example.com) |-- firstname.lastname@example.org (email@example.com, firstname.lastname@example.org) |-- email@example.com (firstname.lastname@example.org, email@example.com, firstname.lastname@example.org, email@example.com, firstname.lastname@example.org, email@example.com, firstname.lastname@example.org, email@example.com)
For Linux systems, you can also install the Azure CLI by building it from the source. For more information on building from source, see the INSTALL file included in the archive.
In a Docker host, run:
docker run -it microsoft/azure-cli
Once the Azure CLI has been installed, you will be able to run the azure command from your command-line user interface (Bash, Terminal, Command prompt, and so on). For example, to run the help command, type the following:
To see the version of the Azure CLI you installed, type the following:
Now you are ready! For access to all of the CLI commands to work with your own resources, connect to your Azure subscription from the Azure CLI.
Microsoft frequently releases updated versions of the Azure CLI. Reinstall the CLI using the installer for your operating system or, if Node.js and npm are installed, update by typing the following (on Linux distributions you might need to use sudo).
npm update -g azure-cli
To learn more about the Azure CLI, download source code, report problems, or contribute to the project, visit the GitHub repository for the Azure CLI.
If you have questions about using the Azure CLI, or Azure, visit the Azure Forums.