PowerShell and CLI Reference 2 – Microsoft AZ-900 Exam

Azure CLI

The Azure Command-Line Interface (CLI) is a set of commands used to manage Azure resources. The Azure CLI is available across Azure services and is designed to get you working quickly with Azure, with an emphasis on automation.

Getting Started with Azure CLI

To use the Azure CLI, you can install it on your local machine, or you can use it in the browser with Azure Cloud Shell. To install it locally, you can download it from the Azure downloads page. Once installed, open your command-line interface and run az login to log in to Azure.

Key Azure CLI Commands

Some of the primary Azure CLI commands include:

● az group create: Creates a new resource group.
● az vm create: Creates a new VM.
● az storage account list: Lists all storage accounts.
● az network vnet create: Creates a virtual network.

The Azure CLI is organized into groups and subgroups that represent the services available in Azure. For example, az vm represents the Azure Virtual Machines service, and the commands under this group pertain to managing virtual machines.

Scripting with Azure CLI

The Azure CLI is designed to be scriptable and can be incorporated into shell scripts or batch files to automate tasks. It supports both Windows Command Prompt and bash scripting languages, and scripts can be written to handle a variety of tasks such as deploying resources, managing configurations, and retrieving information from your Azure environment.

Here’s an example of a bash script that creates a resource group and a Linux virtual machine:

Azure CLI scripts are straightforward and readable, which makes them an excellent choice for quick automation tasks.

Leave a Reply