Checking out the Azure CLI Interactive Mode
Tags: azure, cli
Published: 2020-03-30 22:25:38

---
title: Checking out the Azure CLI Interactive Mode
published: true
description: Learn how to make the most out of the Azure CLI Interactive Mode
tags: azure, cli
---

### Making the most out of the Azure CLI Interactive Mode

#### The power of the Azure CLI

The [Azure CLI](https://docs.microsoft.com/cli/azure/?WT.mc_id=docs-azuredevtips-micrum) is a very powerful tool. You can use it to do basically anything in Azure from the command prompt, including creating and deleting resources like [Web Apps](https://azure.microsoft.com/services/app-service/web/?WT.mc_id=azure-azuredevtips-micrum) and [VMs](https://azure.microsoft.com/services/virtual-machines/?WT.mc_id=azure-azuredevtips-micrum). You can use the [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli?WT.mc_id=docs-azuredevtips-micrum) from your local computer or from the [Azure Cloud Shell](https://shell.azure.com/?WT.mc_id=azure-azuredevtips-micrum).

In this post, we'll explore the [interactive mode of the Azure CLI](https://docs.microsoft.com/cli/azure/interactive-azure-cli?WT.mc_id=docs-azuredevtips-micrum). This is a special mode that enhances the behavior of the CLI. 

#### Prerequisites

If you want to follow along, you'll need the following:
* An Azure subscription (If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=azure-azuredevtips-micrum) before you begin)
* The [Azure CLI](https://docs.microsoft.com/cli/azure/?WT.mc_id=docs-azuredevtips-micrum). You can [download it for Windows, Linux or Mac](https://docs.microsoft.com/cli/azure/install-azure-cli?WT.mc_id=docs-azuredevtips-micrum). Or you can use the [Azure Cloud Shell](https://shell.azure.com/?WT.mc_id=azure-azuredevtips-micrum)

#### Using the Azure CLI Interactive Mode

Let's take a look at the Azure CLI interactive mode. We'll use the Azure Cloud Shell for this and you can also use an Azure CLI that you run on your local machine.

1. Open Azure Cloud Shell, [https://shell.azure.com/](https://shell.azure.com/?WT.mc_id=azure-azuredevtips-micrum)
2. Type **az interactive** to start the interactive mode

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hs1v43j0b7raao8xksp9.png)

(Azure CLI interactive mode)

**Autocomplete and examples**

Azure CLI interactive mode helps you to be more productive. When you use it for a CLI command, like **webapp show**, it will automatically complete your command. It also shows you which parameters are available for the command and what the parameters mean (number 1 in the image). 
You also get a description of what the command does. For instance, for the **webapp show** command, it shows that this command will **"Get the details of a web app"** (number 2 in the image).  
And on top of all of that, the interactive mode also shows examples of how you can use the command (number 3 in the image). 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/eebxioqmnor14rty06j6.gif)

(Azure CLI interactive mode)

**Scoping**

When you use the interactive mode, you don't have to type **az** in front of your command. This is because this mode is already scoped to the az command. And you can scope to other commands as well. If you are working with Web Apps for instance, and don't want to type webapp for every command, you can scope to webapp by typing **%%webapp**. You can also scope deeper by scoping to the webapp create command with **%%create**. You can go back in scope by typing **%%..** to go up one level or by typing **%%** to go back to the root scope. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6o2ubg7at1lok7rtgwn8.gif)

(Scoping in the Azure CLI interactive mode)

**Query**

You can use the Azure CLI to query JSON results from commands that you run. For instance, when you create a [Resource Group](https://docs.microsoft.com/cli/azure/group?WT.mc_id=docs-azuredevtips-micrum), the result is a JSON string that contains the data for that Resource Group, including its id and name. 
In the Azure CLI interactive mode, you can use the JSON results of a previous command in other commands with [JMESPath queries](https://docs.microsoft.com/cli/azure/query-azure-cli?WT.mc_id=docs-azuredevtips-micrum). For instance, when you create a Web App, you can give it the name of a Resource Group that you've created in a previous command with **"?? name"**:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/51i1zt4g0nykm6us4vlt.png)

(JMESPath query in the Azure CLI interactive mode)

**External commands**

You can run shell commands without leaving the Azure CLI interactive mode, like a bash command. You can run shell commands by typing **#[cmd]**, for instance, **#mkdir** to create a new directory. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/32axap0qcsmf4ffepthr.png)

(External commands in the Azure CLI interactive mode)

#### Conclusion

You can be very productive in Azure with the [Azure CLI](https://docs.microsoft.com/cli/azure/?WT.mc_id=docs-azuredevtips-micrum). And you can be even more productive when you use the [Azure CLI interactive mode](https://docs.microsoft.com/cli/azure/interactive-azure-cli?WT.mc_id=docs-azuredevtips-micrum). Go and check it out!

## Live streaming software development

On a side note - If you like my articles, then you might enjoy another project that I'm working on for live streaming. Check out [my channel](https://twitch.tv/mbcrump) and hit the follow button to know when I'm live.