Scott's WeblogThe weblog of an IT pro focusing on cloud computing, Kubernetes, Linux, containers, and networking

Manually Installing Azure CLI on Fedora 25

For various reasons that we don’t need to get into just yet, I’ve started exploring Microsoft Azure. Given that I’m a command-line interface (CLI) fan, and given that I use Fedora as my primary laptop operating system, this led me to installing the Azure CLI on my Fedora 25 system—and that, in turn, led to this blog post.

Some Background

Official packages that can be installed via a package manager are only provided for Ubuntu/Debian. Clearly, this leaves Fedora/CentOS/RHEL users out in the cold.

Users of other Linux distributions are advised to use curl to download a script and pipe that script directly into Bash. (“Danger, Will Robinson!”) Clearly, this is not a security best practice, although I am glad that they didn’t recommend the use of sudo in the mix.

Now, if you dig into #2 a bit, you’ll find that the InstallAzureCli script you’re advised to download via curl really does nothing more than download a Python script named install.py. The install.py Python script really just uses pip and virtualenv to install the Azure CLI.

This left me wondering—why not just advise users to use virtualenv and pip directly, instead of writing a shell script that calls a Python script that calls virtualenv and pip? I posted a message on the Azure Forums to that effect; I’ll update this post when I learn more about the rationale.

Since Microsoft’s install script uses virtualenv and pip, I figured I’d just do that myself manually.

Manually Installing the Azure CLI

With that background in mind, here are the steps I followed to install the Azure CLI.

First, on Fedora 25:

Make sure that the “gcc”, “libffi-devel”, “python-devel”, and “openssl-devel” packages are installed (use dnf to take care of this). On my primary system, these were already installed, so I used a clean Fedora 25 Cloud Base Vagrant image to test. Only these four packages are prerequisites.

Install Pip using sudo dnf install python-pip.

Once Pip is installed, install virtualenv with pip install virtualenv. (I did a sudo -H pip install virtualenv to make virtualenv available to all users on the system, but as far as I know that’s not required.)

Create a new virtual environment with virtualenv azure-cli (feel free to use a different name).

Activate the new virtual environment (typically accomplished by sourcing the <virtualenv>/bin/activate script).

Note that I did have the XCode command-line tools installed—in order to have git—so that may affect things. I tested this on both El Capitan (10.11.6) and Sierra (10.12.5), and the process was identical on both systems.

So there you have it: how to install the Azure CLI using virtualenv and pip on Fedora 25 and macOS. Stay tuned for more Azure-related posts later this year.