← all posts

Azure

Using Azure Cloud Shell and the az CLI for the First Time

A terminal in the browser, already authenticated, with the tooling installed. Once I saw the pattern behind the az commands, the portal started feeling slower than typing.

I'd been doing everything in the Azure portal by clicking through it, which works fine until you need to do the same thing twice. Studying for AZ-900 pushed me into Cloud Shell and the CLI, and the part that surprised me was how little setup it took.

Cloud Shell is a terminal that's already logged in

Cloud Shell runs in the browser, from inside the portal. There's nothing to install, and it comes up already authenticated as the account I'm signed in with, with the Azure tooling already there.

That last part is what made it click for me. Setting up a CLI locally normally means installing it, then authenticating, then figuring out which subscription it's pointed at. Cloud Shell skips all of that, which makes it a genuinely low-friction way to try commands when you're learning and don't want the setup to be the obstacle.

It offers both Bash and PowerShell. I use Bash because that's what I'm used to on macOS.

There's a catch worth knowing: Cloud Shell needs storage for anything you want to persist, so it asks to create a storage account the first time. Files in your home directory survive between sessions because of that. Anything outside it doesn't, since the machine itself is temporary and gets recycled.

The az commands follow one pattern

This is the thing that turned the CLI from intimidating into learnable. Almost every command has the same shape:

az <group> <subgroup> <action> --options

Once I noticed that, I stopped trying to memorise commands and started guessing them, usually correctly:

az group create --name my-resources --location eastus2
az group list
az group delete --name my-resources

The same verbs come back everywhere. create, list, show, delete, update. So if I know how to list resource groups, I can guess how to list web apps:

az webapp list
az vm list
az storage account list

They all work, because it's the same pattern with a different noun.

The commands I actually leaned on

When I didn't know a command, the help flag was faster than searching for documentation:

az vm --help
az vm create --help

That lists the subcommands and every option, in the terminal, for the exact version I'm running.

Two more that were immediately useful:

# which subscription am I actually working in?
az account show

# raw JSON, or just the fields I want
az group list --output table

--output table was the one I didn't expect to care about. The default output is JSON, which is the right default for scripting and hard to read when you just want to see what exists. --output table makes it a readable list.

Why this matters beyond passing an exam

The portal is fine for looking at things and for one-off changes. What it can't do is give me a record of what I did.

A command is repeatable. I can paste it into a document, save it in a project's README, or eventually put it in a script that sets up an environment the same way every time. Clicking through eleven portal screens produces the same result and leaves nothing behind that anyone, including me next month, can follow.

That's the actual shift. Not that the CLI is faster, though for repeated work it is, but that a command is something you can keep and a click isn't.

Where I'd go next

The obvious next step is infrastructure as code proper, where the resources are declared in a file rather than created by commands I run in order. The CLI is still the imperative version of the idea, since I'm telling Azure what to do step by step. But learning the CLI first made the reason for that next step obvious, which it wasn't when all I'd used was the portal.