|
| 1 | +--- |
| 2 | +title: Azure CLI 2.0 Interactive Mode |
| 3 | +description: Use Azure CLI 2.0 in interactive mode. |
| 4 | +keywords: Azure CLI 2.0, interactive mode |
| 5 | +author: rloutlaw |
| 6 | +ms.author: routlaw |
| 7 | +manager: douge |
| 8 | +ms.date: 04/06/2017 |
| 9 | +ms.topic: article |
| 10 | +ms.prod: azure |
| 11 | +ms.technology: azure |
| 12 | +ms.devlang: azurecli |
| 13 | +ms.service: multiple |
| 14 | +ms.assetid: |
| 15 | +--- |
| 16 | + |
| 17 | +# Interactive Azure CLI 2.0 |
| 18 | + |
| 19 | +You can use Azure CLI 2.0 in interactive mode by running the `az interactive` command. |
| 20 | +That places you in an interactive shell where your commands are auto-completed |
| 21 | +and you have access to descriptions of commands and their parameters and command examples. |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +If you're not already logged in to your account, use the `login` command to do that. |
| 26 | + |
| 27 | +## Configure |
| 28 | + |
| 29 | +Interactive mode optionally displays command descriptions, parameter descriptions, and command examples. |
| 30 | +You can turn descriptions and examples on or off using `F1`. |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +You can turn the display of parameter defaults on or off using `F2`. |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +`F3` toggles the display of some key gestures. |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +## Scope |
| 43 | + |
| 44 | +You can scope your interactive mode to a specific command group like `vm` or `vm image`. |
| 45 | +When you do, all commands are interpreted in that scope. |
| 46 | +It's a great shorthand if you're doing all your work in that command group. |
| 47 | + |
| 48 | +Instead of typing these commands: |
| 49 | + |
| 50 | +```azure-cli |
| 51 | +az>> vm create -n myVM -g myRG --image UbuntuLTS |
| 52 | +az>> vm list -o table |
| 53 | +``` |
| 54 | + |
| 55 | +You can scope to the vm command group and type these commands: |
| 56 | + |
| 57 | +```azure-cli |
| 58 | +az>> %%vm |
| 59 | +az vm>> create -n myVM -g myRG --image UbuntuLTS |
| 60 | +az vm>>list -o table |
| 61 | +``` |
| 62 | + |
| 63 | +You can scope to lower-level command groups as well. |
| 64 | +You could scope to `vm image` using `%%vm image`. |
| 65 | +In this case, since we're already scoped to `vm`, we would use `%%image`. |
| 66 | + |
| 67 | +```azure-cli |
| 68 | +az vm>> %%image |
| 69 | +az vm image>> |
| 70 | +``` |
| 71 | + |
| 72 | +At that point, we can pop the scope back up to `vm` using `%%..`, |
| 73 | +or we can scope to the root with just `%%`. |
| 74 | + |
| 75 | +```azure-cli |
| 76 | +az vm image>> %% |
| 77 | +az>> |
| 78 | +``` |
| 79 | + |
| 80 | +## Query |
| 81 | + |
| 82 | +You can execute a JMESPath query on the results of the last command that you executed. |
| 83 | +For example, after you create a VM, you can make sure it has fully provisioned. |
| 84 | + |
| 85 | +```azure-cli |
| 86 | +az>> vm create --name myVM --resource-group myRG --image UbuntuLTS --no-wait |
| 87 | +az>> ? [*].provisioningState |
| 88 | +``` |
| 89 | + |
| 90 | +``` |
| 91 | +[ |
| 92 | + "Creating" |
| 93 | +] |
| 94 | +``` |
| 95 | + |
| 96 | +To learn more about querying the results of your commands, |
| 97 | +see [Query command results with Azure 2.0](query-azure-cli.md). |
0 commit comments