liveBook · Manning

Azure CLI

As explained in Microsoft Azure in Action

Azure CLI is Microsoft's cross-platform command-line tool for managing Azure resources and services.

The Azure CLI lets you manage Azure resources from a command prompt instead of clicking through Azure Portal panes. It is direct and fast for day-to-day work: `az appservice plan list`, for example, lists the App Service plans in a subscription. No buttons required. section 1.6.2

A short command can replace a long portal walkthrough, but it does not make the choices for you. Creating a virtual machine still calls for a name, resource group, image, virtual network, and SSH keys. section 3.4.3

az vm create -n AzureVM -g ActionRG --image UbuntuLTS 
–vnet-name ActionVNet --generate-ssh-keys

This VM command supplies those choices directly, including an Ubuntu image and generated SSH keys. section 3.4.3

For a Function App, `az functionapp create` needs a storage account for function metadata and code. Use one in the same resource group; placing it in the same region is recommended to reduce travel time between the app and storage. A consumption-plan location selects the app’s region. section 8.2

C:/> az functionapp create --name ActionFunctionApp 
--storage-account alpacamabagsstorage 
--consumption-plan-location "australiaeast" --resource-group AlpacaRG 
--functions-version 4

The command brings the Function App name, storage account, region, resource group, and Functions version together. section 8.2

Some resources take more than one command. Azure SQL Database setup creates a server first, then a database on that server. The server command requires an authentication choice: an admin username and password, or `--enable-ad-only-auth` for Entra ID authentication. Choose the admin name carefully; it cannot be changed later. The database command’s `--service-objective` sets a pricing tier, so a bigger choice can mean a bigger bill. section 10.3.1

C:/> az sql db create --resource-group BanningRG 
--server BanningBooksServer --name BanningBooksDB 
--service-objective Basic

Here, `Basic` is the database’s service objective—the pricing-tier choice. section 10.3.1

Cosmos DB shows why reading flags matters. Its account command selects MongoDB compatibility, a region and failover priority, zone redundancy, and a default consistency level. Creating the account is only the first step; a database and collection follow. section 11.1

C:/> az cosmosdb create --name alpacacosmosdbaccount 
--resource-group AlpacaRG --kind MongoDB 
--locations regionName=australiacentral failoverPriority=0 
isZoneRedundant=False --default-consistency-level "Session" 
--capabilities EnableMongo

Read the options before running this one: it selects MongoDB support, disables zone redundancy, and sets Session consistency. section 11.1

The CLI can also apply configuration stored in a file. A Blob Storage lifecycle policy can move blobs to cool storage after 30 days without modification, archive them after 90 days, and delete them after 365 days. Save the JSON as `policy.json`, then pass it to the management-policy command. section 9.5.1

C:/> az storage account management-policy create 
--account-name banningstorage --resource-group BanningRG 
--policy @policy.json

The `@policy.json` argument supplies the saved policy file to the storage account command. section 9.5.1

How Microsoft Azure in Action covers it

How deep it goes
Walks through resource-creation commands and selected flags, but does not show CLI installation or sign-in.
Examples
Demonstrates VM creation and Function App creation with concrete `az` commands.
What it assumes
Builds on a portal-based VM walkthrough and earlier resource-group usage while explaining Function App command parameters.
What you can do after
Apply it via Azure CLI to create a VM and Function App with the required resource and storage choices.
How it connects
Connects Azure Portal, virtual machines, and Azure Functions through alternative resource-creation workflows.

Also explained in

Compare how 4 books explain Azure CLI →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microsoft Azure in Action. The section links point to the parts of the book it draws on.