The Azure CLI

Now that you’ve got an understanding of the Azure Cloud Shell that you’ll use throughout this chapter, let’s dig into our first tool: the Azure CLI. What is it? How do you use it? What are some special features to look out for? We’ll answer each question in this lesson.

The Azure CLI is a cross-platform, command-line tool built-in Python that creates, updates, and removes nearly all Azure resources. It provides you a fairly easy-to-understand CLI that uses the various Azure APIs behind the scenes.

This lesson is meant to be a brief overview of the Azure CLI. If you’d like to learn more about this topic, check out the Microsoft documentation.

No setup needed using Cloud Shell

Since you’ll be using the Cloud Shell to use the Azure CLI, it doesn’t need to be installed. As of this writing, the Cloud Shell uses Azure CLI v2.18.

However, if you’d like to use it on your local Windows, Linux, or macOS system, check out these instructions to install it.

Cloud Shell also prevents you from having to authenticate with the Azure CLI. Since you’ve already authenticated via the Azure portal, Cloud Shell “passes on” that authentication to the Azure CLI, so everything just works.

If you choose to install and run the Azure CLI locally, you can authenticate the Azure CLI using the command az login. Once you authenticate, be sure to set the default subscription using az account set. If you don’t set the default subscription, you’ll have to specify the subscription for every command you issue.

Run the following command to set the default subscription changing the [subscription name] placeholder with the name of your subscription.

az account set --subscription '[subscription name]'

Get hands-on with 1000+ tech skills courses.