Azure CLI 2.0 Preview via Docker

In the spirit of microblogging I'm going to quickly document how I decided to install the new Azure CLI 2.0. For something like this, usually I'd go ahead and install all the requirements (Python in this case) and then add the package using the native package manager. However, I'm on a nice, new, clean Surface Book and I'm attempting to keep it that way. Therefore, I opted to install via Docker, seeing as I already had that on my machine.

To create a Docker container with Azure CLI 2.0 installed couldn't be easier, just execute the following command from your terminal.

docker run -it azuresdk/azure-cli-python:latest bash  

This will give you a bash prompt from where you can manage your Azure resources. This is nice, but a little bit verbose. As an optional extra, I decided to create an alias in my PowerShell profile like so:

New-Function Start-AzureCLI  
{
    docker run -it azuresdk/azure-cli-python:latest bash
}
New-Alias daz Start-AzureCLI  

Now I can simply launch the new CLI using terminal as follows:

> daz
bash-4.3# az ...  

No messing around with Python2.7 vs Python3.5 installations and making a mess of your $PATH.