Connect to Azure Using Azure CLI from a Docker Container

In this blog post, I will show you how to download and the Microsoft Azure CLI Docker Container image and run Azure CLI commands.

Azure CLI command like utility is similar to AWS CLI and allow us to manage Microsoft Azure resources from the command line.

Currently, Azure CLI is available using an installer where you install on your machines or using Cloud Shell.

The Docker container image gives us the flexibility to Azure CLI commands from inside a container and not worrying about the local machines.

It also offers a better security environment.

Get Started

To download the Azure CLI image which runs on Linux and Microsoft Containers, I will use the following pull command.

docker pull microsoft/azure-cli

As you can see below, The image size is 910 MB.

docker images microsoft/azure-cli

To run a Docker container with the Azure CLI command, I will use the following command.

Note – I’m using the –rm switch which will delete the container on exit.

docker run --rm -it microsoft/azure-cli:latest

From inside the container I can use the –help switch below to view all the available az cli commands.

az --help

To connect to Microsoft Azure, I will use the following command an authenticate.

Az login

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.