AZ-104 Azure CLI and PowerShell Reference

The Azure CLI and Azure PowerShell commands AZ-104 asks you to read and pick between, plus the resource types those commands create. Written for the Azure Administrator exam and useful revision after AZ-900.

Azure CLI essentials

CommandWhat it does
az loginSign in interactively in the browser
az account showShow the subscription and tenant you are working in
az account list --output tableList every subscription your account can reach
az account set --subscription "<name or id>"Change the active subscription
az group create --name <rg> --location <region>Create a resource group
az group delete --name <rg> --yesDelete a resource group and everything inside it
az resource list --resource-group <rg> -o tableList the resources in a group
az vm list -d -o tableList VMs with their power state (-d shows details)
az vm start --resource-group <rg> --name <vm>Start a stopped VM
az vm stop --resource-group <rg> --name <vm>Shut the guest down; the VM stays allocated and still bills
az vm deallocate --resource-group <rg> --name <vm>Release the compute so compute charges stop; disks still bill
az storage account create --name <name> --resource-group <rg> --sku Standard_LRSCreate a storage account with a redundancy SKU
az network nsg rule create --resource-group <rg> --nsg-name <nsg> --name <rule> --priority 200 --access AllowAdd a rule to a network security group
az role assignment create --assignee <user> --role "Reader" --scope <scope>Assign a built-in RBAC role at a scope
az deployment group create --resource-group <rg> --template-file <file>Deploy an ARM or Bicep template into a resource group

Azure PowerShell equivalents

CmdletWhat it does
Connect-AzAccountSign in to Azure
Get-AzContextShow the current subscription and tenant context
Get-AzSubscriptionList the subscriptions you can reach
Set-AzContext -Subscription "<id>"Change the active subscription
New-AzResourceGroup -Name <rg> -Location <region>Create a resource group
Remove-AzResourceGroup -Name <rg> -ForceDelete a resource group and its contents
Get-AzResource -ResourceGroupName <rg>List the resources in a group
Get-AzVM -StatusList VMs with their power state
Start-AzVM -ResourceGroupName <rg> -Name <vm>Start a VM
Stop-AzVM -ResourceGroupName <rg> -Name <vm>Stop and deallocate a VM by default
Stop-AzVM -StayProvisionedStop the VM but keep it allocated
New-AzStorageAccountCreate a storage account
New-AzRoleAssignment -SignInName <user> -RoleDefinitionName <role> -Scope <scope>Assign an RBAC role
New-AzResourceGroupDeployment -ResourceGroupName <rg> -TemplateFile <file>Deploy a template into a resource group

Core resource types

ResourceWhat it is for
Management groupContainer above subscriptions; policy and RBAC assigned here inherit downward
SubscriptionBilling and quota boundary; holds resource groups
Resource groupLifecycle container; every resource belongs to exactly one group
Virtual networkPrivate address space in one region
SubnetA slice of the virtual network address space
Network security groupAllow and deny rules by source, destination, port and protocol; attach to a subnet or a NIC
NSG rule priorityLower number is evaluated first; user rules use 100 to 4096
Application security groupGroups NICs so NSG rules can name a group instead of IP addresses
Route tableUser defined routes that override Azure system routes
Azure BastionRDP and SSH to VMs from the portal without a public IP on the VM
Load BalancerLayer 4 distribution across a backend pool, public or internal
Application GatewayLayer 7 routing by URL path or host, with an optional web application firewall
Availability setSpreads VMs across fault domains and update domains inside one datacenter
Availability zonePhysically separate locations within one region
Virtual machine scale setIdentical VMs that scale out and in on a rule

Storage services, tiers and redundancy

ItemWhat it means
Blob storageObject storage for unstructured data, organized in containers
Azure FilesManaged SMB and NFS shares you can mount from a client
Queue storageMessage store for decoupling application components
Table storageNoSQL key attribute store for structured, non-relational data
Hot tierFrequent access; highest storage cost, lowest access cost
Cool tierInfrequent access; 30 day minimum retention before early deletion charges
Cold tierRarer access; 90 day minimum retention
Archive tierOffline; 180 day minimum retention, and the blob must be rehydrated before it can be read
LRSThree synchronous copies inside a single datacenter in the primary region
ZRSThree synchronous copies across three availability zones in the primary region
GRSLRS in the primary region plus asynchronous replication to a secondary region
GZRSZRS in the primary region plus asynchronous replication to a secondary region
RA-GRS and RA-GZRSSame as GRS and GZRS, with read access to the secondary endpoint

Built-in RBAC roles

RoleWhat it grants
OwnerFull management of resources, including assigning roles to others
ContributorFull management of resources, but cannot assign roles
ReaderView resources, change nothing
User Access AdministratorManage who has access to resources, without managing the resources
Virtual Machine ContributorManage VMs, but not the virtual network or storage account they connect to
Network ContributorManage networking resources, but not access to them
Storage Blob Data ContributorRead, write and delete blob data (data plane, not the account itself)
Storage Blob Data ReaderRead and list blob data
Role assignmentSecurity principal plus role definition plus scope; assignments inherit to child scopes

Governance: policy, locks and tags

FeatureWhat it does
Azure PolicyEvaluates resources against rules and acts on the result
Deny effectBlocks the create or update request outright
Audit effectAllows the request and records non-compliance
Append and Modify effectsAdd or change fields such as tags on the resource being written
DeployIfNotExistsDeploys a related resource when the condition is not met; needs a managed identity
InitiativeA set of policy definitions assigned and reported as one unit
CanNotDelete lockRead and modify allowed, delete blocked
ReadOnly lockRead allowed, changes and deletes blocked
Lock inheritanceLocks apply to child scopes, and the most restrictive lock wins
TagsName and value pairs for cost reporting; child resources do not inherit them by default

Ready to test yourself?

Memorizing a table is a start, practice questions make it stick.