The goodness of Azure CLI Interactive shell


Off late I have been working a lot with terminal and command line interface (CLI) for things like Docker, Azure, Kubernetes etc. While working with these wonderful technologies they provide an easy way to auto-complete different commands. Without auto-completion its a nightmare to remember the syntax for each & every command. Even with auto-completion enabled sometimes it is really a pain to remember different parameters a command can take. Sometimes you have multiple options which can be assigned as a parameter value. Most of the times I find using the help feature with –h or –help option to know all these details about the command, its parameters and available options.

If you are starting new with some technology like Kubernetes or with cloud provider like Azure which has various services which can be managed using CLI it can be really difficult to get started. When it comes to Azure CLI there is an easy option called Interactive which simplifies things to a great extent. This short post is about my experience of using the Azure CLI interactive mode which I happened to discover by accident.

Azure CLI Interactive mode

First of all you need to install the latest version of Azure CLI 2.0. We need to execute the following command in our favorite terminal. I use zsh as my default terminal along with the oh-my-zsh plugin.

az interactive 

Once we enter the interactive mode, the terminal changes look & feel. Lets use some of the commands from our previous post on provision Kubernetes cluster in AKS.

Auto suggestion resource names

The moment I start typing, I can see auto suggestion for different resources that can be managed using Azure CLI. AZ autocomplete resource name

Lets choose aks as the resource we want to interact with using the command line. We will use the create command.

Command details

AZ command details

Once we have chosen the command, the bottom part of the screen is refreshed automatically or I should say magically to display relevant details of the command. We can find command description in the first pane. The next pane shows some examples how the command can be executed. In the above screenshot we can see 3 examples how the create command can be invoked with different parameters. At the bottom pane we can see the keyboard shortcut keys for layout(F1), default values (F2) etc. On the rightmost corner we can also see the current active subscription.

Parameter details with description

As soon as we finish writing create, we can see the auto suggestion popping up for the parameters along with the description of the parameter.

AZ parameters list with explanation

This is simply amazing. I get to know which are the required parameters and which are the optional parameters at one glance. I also get helpful description for each parameter with hints like in case of kubrnetes-version. Here is a quick example of the hint

AZ parameter suggestions with default help

I did not know that the default group can be configured using the command az configure –default group=<name>. I find it quite useful that such hints can help to learn the different commands quite fast.

Filter & Auto suggest existing resources

Another interesting feature I found out about the interactive shell was its capability to filter existing resources. Let me take an example once again. I have some resource groups already created. When I try to add the –resource-group parameter, I get an auto suggestion for all the available groups as shown below

AZ autocomplete existing resources

I no longer need to remember the lengthy names of different resources.


I touched just the tip of the iceberg during this post. I found it very useful and a huge productivity gain when I started using the interactive shell. I hope you can make good use of this when you are trying to familiarize yourself with different options related to managing numerous resources using Azure CLI. Playing around with Azure command line has never been so much fun before. Interactive command line makes the whole learning experience much more exciting. I am pretty sure that once you get used to the amazing az cli you would never want to go back to the –h –help option ever again. I wish other tools will also implement such features.

Until next time code with passion and strive for excellence.


No comments:

Post a Comment