Azure CLI interactive mode
You can use Azure CLI in interactive mode by running the
az interactive command. The Azure CLI interactive mode places you in an interactive shell with auto-completion, command descriptions, and examples.
We're not using the default style here, which doesn't read as well on a black background.
If you're not already signed in to your account, use the
What is the Azure CLI interactive mode?
Azure CLI Interactive Mode (az interactive) provides users an interactive environment to run Azure CLI commands. The interactive mode makes it easier for you to learn the Azure CLI’s capabilities, command syntax, and output formats. It provides autocompletion dropdowns, autocached suggestions combined with runtime documentation, including examples how each command is used. Azure CLI Interactive Mode aims to provide an ideal experience for users learning to use Azure CLI commands.
Interactive mode optionally displays command descriptions, parameter descriptions, and command examples.
Turn descriptions and examples on or off using
You can turn the display of parameter defaults on or off using
F3 toggles the display of some key gestures.
You can scope your interactive mode to a specific command group like
When you do, all commands are interpreted in that scope.
It's a great shorthand if you're doing all your work in that command group.
Instead of typing these commands:
az>> vm create -n myVM -g myRG --image UbuntuLTS az>> vm list -o table
You can scope to the vm command group and type these commands:
az>> %%vm az vm>> create -n myVM -g myRG --image UbuntuLTS az vm>>list -o table
You can scope to lower-level command groups as well.
You could scope to
vm image using
In this case, since we're already scoped to
vm, we would use
az vm>> %%image az vm image>>
At that point, we can pop the scope back up to
or we can scope to the root with just
az vm image>> %% az>>
You can execute a JMESPath query on the results of the last command that you executed by using
??followed by a JMESPath query.
For example, after you created a group, you can retrieve the id of the new group.
az>> group create -n myRG -l westEurope az>> "?? id"
You can also use this syntax to use the result of the previous command as an argument for your next command.*
For instance after having listed all groups, list all the resources of type
virtualMachineon the first group whose location is westeurope.
az>> vm create --name myVM --resource-group myRG --image UbuntuLTS --no-wait -o json az>> group list -o json az>> resource list -g "?? [?location=='westeurope'].name | " --query "[?type=='Microsoft.Compute/virtualMachines'].name
To learn more about querying the results of your commands, see Query command results with the Azure CLI.
You can run shell commands without leaving interactive mode using
Some commands have lots of examples.
You can scroll to the next page of examples using
CTRL-N and the previous page using
You can also look at a specific example using
az>> vm create ::8
Submit and view feedback for