A few months ago, Azure CLI 2.0 was released. It provides a command line interface to manage/administer Azure resources. Azure CLI is optimized to run automation scripts composed of multiple commands, hence the commands and the overall user experience is not interactive. Azure CLI Interactive Mode (az interactive) provides an interactive environment to run Azure CLI 2.0 commands, which is ideal for new users learning the Azure CLI’s capabilities, command structures, and output formats. It provides autocomplete dropdowns, auto-cached suggestions combined with on the fly documentation, including examples of how each command is used. Azure CLI Interactive Mode provides an experience that makes it easier to learn and use Azure CLI commands.
Features
Gestures
The interactive mode implements gestures that can be used by users to customize it. F3 function key in the toolbar can be used to look up all the available gestures at any time.
Scoping
The interactive mode allows users to scope their commands to a specific group of commands. If you only want to work with ‘vm’ commands, you can use the following gesture to set the right scope so that you don’t have to type ‘vm’ with all subsequent commands:
$ %% vm
Now, all the completions are ‘vm’ specific.
To remove a scope, the gesture is:
$ %% ..
Or, if I wish to remove all scoping:
$ %%
Scrolling through examples
The interactive mode lists many examples for each command contextually, as you type your commands. However, some commands, like ‘vm create’ have too many examples to fit on the terminal screen. To look through all examples, you can scroll through the example pane with CTRLY and CTRLN for ‘up’ and ‘down’ , respectively.
Step-by-step examples
With all the examples, you can easily select a specific one to view in the example pane.
$ [command] :: [example number]
The example number is indicated in the example pane. The interactive mode takes the user through a step by step process to create the command and execute it.
Commands outside the interactive mode
Azure CLI Interactive Mode allows a user to execute commands outside of Azure CLI from within the interactive mode itself. So you don’t need to exit out of the 'az interactive' to add something to git, for example. Users can execute commands outside the shell with the gesture:
$ #[command]
Query Previous Command
You can use a jmespath query on command outputs of type ‘json’ to quickly find properties/values that you want.
$ ? [jmespath query]
Exit Code
There is a gesture that allows users to see the exit code of the last command they ran, to check if it executed properly.
$ $
Installation
Because the interactive mode comes with CLI, see the installation instructions of Azure CLI GitHub
To start the application
$ az interactive
Updates
To get updates, update your CLI to the newest version. You'll want to uninstall the deprecated shell applications with this command:
$ pip uninstall azure-cli-shell
Welcome to Azure CLI Interactive Shell
Azure CLI Interactive Shell is open source and located as the 'interactive' command module in the CLI repository. If there are any issues, they can be filed on the Github repository or e-mailed to azfeedback. You can also use the “az feedback” command directly from within 'az interactive' or az as well.