Azure CLI: Get Started

Your essential guide to begin using the Azure Command-Line Interface.

Introduction to Azure CLI

The Azure Command-Line Interface (CLI) is a powerful tool for managing Azure resources. It allows you to interact with Azure services from your command line, automate tasks, and deploy infrastructure efficiently. This tutorial will guide you through the initial steps of installing and using the Azure CLI.

Why use Azure CLI?

Step 1: Installation

First, you need to install the Azure CLI on your local machine. Choose the method appropriate for your operating system.

1

Download and Install

Visit the official Azure CLI installation page for detailed instructions for your OS:

Installation Guide

2

Verify Installation

After installation, open your terminal or command prompt and run the following command to check if the CLI is installed correctly:

az --version

You should see output similar to this (versions may vary):

azure-cli 2.37.0 ...

Step 2: Login to Azure

Once installed, you need to log in to your Azure account to start managing resources.

1

Run the Login Command

Execute the following command in your terminal:

az login

This will open a web browser where you can sign in with your Azure credentials. If you are using a headless environment, follow the instructions to log in using a device code.

2

Select Your Subscription (if applicable)

If you have multiple Azure subscriptions, you might need to set the active subscription. First, list your subscriptions:

az account list --output table

Then, set your desired subscription:

az account set --subscription "Your Subscription Name or ID"

Step 3: Your First Azure CLI Command

Let's try a simple command to get information about your Azure account.

1

Get Account Information

Use the following command to display your current account details:

az account show --output table

This command will output details about your active subscription, tenant, user information, and more in a readable table format.

Next Steps

Congratulations! You've successfully installed and logged in with the Azure CLI. Here are some suggestions for your next steps:

The Azure CLI is a vast tool. Keep practicing and exploring its capabilities to maximize your Azure management efficiency.

Explore More Azure Tutorials