Install Azure CLI 2.0
Install the new version of the Azure CLI today! We've improved and updated it to provide a great native command-line experience for managing Azure resources. It can be used on macOS, Linux, and Windows. For information about the latest release, see the release notes.
Note
If you are using the Azure Service Management (ASM) model, install Azure CLI 1.0.
Install on macOS
On macOS, you are able to install either with Homebrew or manually.
Install with Homebrew
If you don't have it already, install Homebrew by following the Homebrew installation instructions.
If you have previously installed the CLI manually, follow the manual uninstall instructions.
Update your local Homebrew repositories.
brew updateInstall the
azure-clipackage.brew install azure-cli
Note
If you previously installed the Azure CLI 1.0 with Homebrew, instead of installing the package you can get CLI 2.0 through the regular Homebrew upgrade process.
brew upgrade
Install manually
Install Azure CLI 2.0 with
curl.curl -L https://aka.ms/InstallAzureCli | bashYou may have to restart your shell for some changes to take effect.
exec -l $SHELLRun the CLI from the command prompt with the
azcommand.
Install on Windows
Install with MSI for the Windows command-line
To install the CLI on Windows and use it in the Windows command-line, download and run the Azure CLI Installer (MSI).
Install with apt-get for Bash on Ubuntu on Windows
If you don't have Bash on Windows, install it.
Open the Bash shell.
Modify your sources list.
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \ sudo tee /etc/apt/sources.list.d/azure-cli.listRun the following sudo commands:
sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 52E16F86FEE04B979B07E28DB02C46DF417A0893 sudo apt-get install apt-transport-https sudo apt-get update && sudo apt-get install azure-cliRun the CLI from the command prompt with the
azcommand.
Install with apt package manager
For distributions using the apt package manager such as Ubuntu or Debian, you can install Azure CLI 2.0 via apt-get.
Note
To install the CLI, your distribution must have packages with the following software:
Modify your sources list:
32-bit system
echo "deb https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \ sudo tee /etc/apt/sources.list.d/azure-cli.list64-bit system
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \ sudo tee /etc/apt/sources.list.d/azure-cli.list
Run the following sudo commands:
sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 52E16F86FEE04B979B07E28DB02C46DF417A0893 sudo apt-get install apt-transport-https sudo apt-get update && sudo apt-get install azure-cliRun the CLI from the command prompt with the
azcommand.
Install with yum package manager
For distributions which use the yum package manager such as Red Hat Enterprise Linux (RHEL), Fedora, or CentOS, you can install Azure CLI 2.0 via yum.
Note
To install the CLI, your distribution must have packages with the following software:
Import the Microsoft repository key:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.ascCreate local
azure-clirepository information:sudo sh -c 'echo -e "[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo'Update the
yumpackage index and install:yum check-update sudo yum install azure-cliRun the CLI from the command prompt with the
azcommand.
Install with zypper package manager
For distributions which use the zypper package manager such as OpenSUSE or SLE, you can install Azure CLI 2.0 via zypper.
Note
To install the CLI, your distribution must have packages with the following software:
Import the Microsoft repository key:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.ascCreate local
azure-clirepository information:sudo sh -c 'echo -e "[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/zypp/repos.d/azure-cli.repo'Update the
zypperpackage index and install:sudo zypper refresh sudo zypper install azure-cliRun the CLI from the command prompt with the
azcommand.
Install with Docker
We maintain a Docker image preconfigured with the Azure CLI 2.0.
Install the CLI using docker run.
docker run -it azuresdk/azure-cli-python:<version>
See our Docker tags for available versions.
The CLI is installed on the image as the az command in /usr/local/bin.
Note
If you want to pick up the SSH keys from your user environment,
you can use -v ${HOME}:/root to mount $HOME as /root.
docker run -it -v ${HOME}:/root azuresdk/azure-cli-python:<version>
Install on Linux without a package manager
It is recommended that you install the CLI with a package manager if you are able to. If you do not want to add Microsoft's repositories, or are working with a distribution which does not have a provided package, you can manually install the CLI.
Install the prerequisites based on your Linux distribution.
Platform | Prerequisites ----------------------|--------------------------------------------- Ubuntu 15.10 or 16.04 | sudo apt-get update && sudo apt-get install -y python libssl-dev libffi-dev python-dev build-essential Ubuntu 12.04 or 14.04 | sudo apt-get update && sudo apt-get install -y python libssl-dev libffi-dev python-dev Debian 8 | sudo apt-get update && sudo apt-get install -y python libssl-dev libffi-dev python-dev build-essential Debian 7 | sudo apt-get update && sudo apt-get install -y python libssl-dev libffi-dev python-dev CentOS 7.1 or 7.2 | sudo yum check-update; sudo yum install -y gcc python libffi-devel python-devel openssl-devel RedHat 7.2 | sudo yum check-update; sudo yum install -y gcc python libffi-devel python-devel openssl-devel SUSE OpenSUSE 13.2 | sudo zypper refresh && sudo zypper --non-interactive install curl gcc python python-xml libffi-devel python-devel openssl-devel
If your distribution is not listed above, you will need to install Python 2.7 or later, libffi, and OpenSSL 1.0.2.
Install the CLI with
curl.curl -L https://aka.ms/InstallAzureCli | bashYou may have to restart your shell for some changes to take effect.
exec -l $SHELLRun the CLI from the command prompt with the
azcommand.
Troubleshooting
If you encounter an issue during CLI install, check this section to see if your particular case is covered. If your issue is not here, please file a Github issue.
curl "Object Moved" error
If you get an error from curl related to the -L parameter, or an error message including the text "Object Moved", try using the full URL instead of the aka.ms redirect:
curl https://azurecliprod.blob.core.windows.net/install | bash
az command not found
You may need to clear your shell's command hash cache. Run
hash -r
and see if the problem is resolved. The command may also not be in your $PATH. Make sure that <install path>/bin appears in your $PATH, and restart your shell if necessary.
Uninstall CLI 1.x versions
If you have an earlier CLI 1.x version available on your system, you can uninstall it based upon the type of install used.
Uninstall with npm
Remove the older CLI with npm uninstall.
npm uninstall -g azure-cli
Uninstall with distributable
If you installed via the Azure CLI Installer (MSI) or a macOS package, use the same tool to remove your install.
Uninstall with Docker
If you installed a Docker image to use the earlier CLI version, remove that image and any associated containers. You can then re-create the containers after installing the new Docker image as described in the install instructions.
docker rmi -f microsoft/azure-cli
Update the CLI
To update the Azure CLI, use the same method that you used to install it.
Update with Homebrew
If you previously installed manually, follow the install with Homebrew instructions.
Update your local Homebrew repository information.
brew updateUpgrade your installed packages.
brew upgrade
Update with MSI
Run the Azure CLI Installer (MSI) again.
Update with apt
Use apt-get upgrade to update the CLI package.
sudo apt-get update && sudo apt-get upgrade
Note
This will upgrade all of the installed packages on your system which have not had a dependency change.
To upgrade only the CLI, use apt-get install.
sudo apt-get update && sudo apt-get install --only-upgrade -y azure-cli
Update with yum
Update the Azure CLI with the yum update command.
yum check-update
sudo yum update azure-cli
Update with zypper
You can update the package with the zypper update command.
sudo zypper refresh
sudo zypper update azure-cli
Update with Docker
Update your local image with
docker pull.docker pull azuresdk/azure-cli-pythonGet the containers currently using the CLI image.
docker container ls -a --filter 'ancestor=azuresdk/azure-cli-python'CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 34a868beb2ab azuresdk/azure-cli-python:latest "/bin/sh -c bash" 8 minutes ago Exited (0) 8 minutes ago inspiring_benz
Note
If you installed a specific version of the image, you will need to add :<version> to the end of the image name.
Halt and recreate the containers.
docker stop inspiring_benz docker rm inspiring_benz docker run azuresdk/azure-cli-python
Update manually
Follow the manual installation instructions for macOS or Linux to update.
Uninstall
If you decide to uninstall the CLI, we're sorry to see you go. You should uninstall using the same method that you used to install the CLI.
Uninstall with Homebrew
Uninstall the azure-cli package.
brew uninstall azure-cli
Uninstall with MSI
Run the MSI again and choose uninstall.
Uninstall with apt
Uninstall via apt-get remove:
sudo apt-get remove -y azure-cli
Uninstall with yum
Remove the package from your system.
sudo yum remove azure-cliIf you do not plan to reinstall the CLI, remove the repository information.
sudo rm /etc/yum.repos.d/azure-cli.repoIf you removed the repository information, also remove the Microsoft GPG signature key.
MSFT_KEY=`rpm -qa gpg-pubkey /* --qf "%{version}-%{release} %{summary}\n" | grep Microsoft | awk '{print $1}'` rpm -e --allmatches gpg-pubkey-$MSFT_KEY
Uninstall with zypper
Remove the package from your system.
sudo zypper remove -y azure-cliIf you do not plan to reinstall the CLI, remove the repository information.
sudo rm /etc/zypp/repos.d/azure-cli.repoIf you removed the repository information, also remove the Microsoft GPG signature key.
MSFT_KEY=`rpm -qa gpg-pubkey /* --qf "%{version}-%{release} %{summary}\n" | grep Microsoft | awk '{print $1}'` rpm -e --allmatches gpg-pubkey-$MSFT_KEY
Uninstall with Docker
If you installed a docker image, you will need to remove any containers running it, and then delete the local image.
Get the containers which are running the azure-cli image.
docker container ls -a --filter 'ancestor=azuresdk/azure-cli-python'CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 34a868beb2ab azuresdk/azure-cli-python:latest "/bin/sh -c bash" 8 minutes ago Exited (0) 8 minutes ago inspiring_benzDelete any containers with the CLI image.
docker rm 34a868beb2abRemove the locally installed CLI image.
docker rmi azuresdk/azure-cli-python
Note
If you installed a specific version of the image, you will need to add :<version> to the end of the image name.
Uninstall manually
If you used the script at https://aka.ms/InstallAzureCli to install the CLI, you can uninstall it with these steps.
Remove the installed files.
rm -r <install location>/lib/azure-cli rm <install location>/bin/azDelete the line
<install location>/lib/azure-cli/az.completionfrom<install location>/.bash_profile.If your shell uses a command cache, reload it.
hash -r
Note
The default install location is /Users/<username> for macOS and /home/<username> for Linux.
Report CLI issues and feedback
If you encounter any bugs with the tool,
file an issue in the Issues section of our GitHub repository.
To provide feedback from the command line, use the az feedback command.



