Skip to content

Latest commit

 

History

History
159 lines (105 loc) · 7.01 KB

xplat-cli-install.md

File metadata and controls

159 lines (105 loc) · 7.01 KB

Install the Azure CLI

This article describes how to install the Azure Command-Line Interface (Azure CLI). The Azure CLI provides a set of open-source shell-based commands for creating and managing resources in Microsoft Azure.

[AZURE.INCLUDE learn-about-deployment-models]

The Azure CLI is written in JavaScript, and requires Node.js. It is implemented using the Azure SDK for Node, and released under an Apache 2.0 license. The project repository is located at https://github.com/azure/azure-xplat-cli.

[AZURE.NOTE] If you've already installed the Azure CLI, connect it with your Azure resources. For more, see How to connect to your Azure Subscription.

How to install the Azure CLI

There are a few ways to install the Azure CLI.

  1. Use an installer
  2. Install Node.js and npm and then use the npm install command
  3. Run Azure CLI as a Docker container

Once the Azure CLI has been installed, you will be able to use the azure command from your command-line interface (Bash, Terminal, Command prompt, and so on) to access the Azure CLI commands.

Use an installer

The following installer packages are available:

Install and use Node.js and npm

If Node.js is already installed on your system, use the following command to install the Azure CLI:

npm install azure-cli -g

[AZURE.NOTE] On Linux distributions, you may need to use sudo to successfully run the npm command.

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.

[AZURE.NOTE] The commands here are taken from the Joyent 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]

Install node.js and npm on Windows and Mac OS X

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 window and typing

npm -v

If it shows the version of the npm installed, you can go ahead and install Azure CLI with

npm install -g azure-cli

At the end of the installation, you should see something similar to the following:

[AZURE.NOTE] 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.

Using a Docker container

In a Docker host, run:

	docker run -it microsoft/azure-cli

Executing Azure CLI commands

Once the Azure CLI has been installed, you will be able to use the azure command from your command-line user interface (Bash, Terminal, Command prompt, and so on) to access the Azure CLI commands. For example, to execute the help command in Windows launch a Command window and type the following:

	c:\> azure help

Now you are ready! Next you can connect to your Azure subscription from the Azure CLI and start using the azure commands.

Additional resources