You now have the ability to consume Azure services through existing Azure SDKs
, Azure PowerShell
or Azure CLI. Azure CLI – Command Line Interface, is cross platform and is supported on Linux, Mac and Windows clients. In this blog, I'll demonstrate how to take advantage of the newly released Azure CLI Docker image (depicted below) to quickly get going with Azure CLI regardless of what client OS or Linux Distribution you’re using as long as you have access to Docker host
The advantages of running Azure CLI as Docker container is twofold. First, this will allow you to get started quickly by running only 1 command. Secondly, once you start your advanced Azure CLI usage, this will allow you to move between different clients in your development environments and provide the ability to preserve all the work you have done and get access to it from another client as one package (i.e. a container). These are actually some of the key use cases of Docker containers in general, but now we can put them in use in our scenarios to run Azure CLI as a Docker container image. In order to run Azure CLI as Docker container:
- Ensure you have access to a Docker host – to provision a Docker host on Azure Linux VM – see here.
$ docker run -it microsoft/azure-cli
Once you run the above command, you will be prompted with Azure CLI already pre-installed and ready for use. From this point on you can access the latest Azure CLI bits and supported commands as well as the latest bits. The first thing you probably want to do at this point is login to your subscription and start managing your Azure resources. The first time you run the above command it might take a couple of minutes to download the image from the Docker Hub repository however subsequent runs will utilize the locally available image. For details using Azure CLI across Azure service, visit Azure CLI GitHub repository: Microsoft Azure Cross Platform Command Line
, and if you're using Azure CLI to manage Azure Virtual machines, reference
Once your subscription is setup and you have the Azure CLI environment that you would like to continue to use in the different client, you can commit your newly created container as a new personal image and save it in your private repository for future usage:
$ docker run -it <your private repo>/azure-cli Warning: If you login to your subscription and capture a new image, make sure you do NOT push the newly created image publically as it will include your private subscription information. Instead, save the image locally or use your private repository and continue to use the same above command.