Azure CLI - My commonly used commands

Posted on | 117 words | ~1mins

Subscriptions

Subscriptions - List all

az account list --output table

Subscriptions - Show current

az account show --output table

Subscriptions - Set current

az account set --subscription "{Subscription Name}"

Function App

Function App - List all

az functionapp list --query "[].{Name:name, Location:location, State:state}" --output table

Function App - list stopped

az functionapp list --query "[?state=='Stopped'].{Name:name, Location:location, State:state}" --output table

App Service

App Service - list stopped

az webapp list --query "[?state=='Stopped'].{Name:name, Location:location, State:state}" --output table

Cosmos DB

Cosmos DB - list all

az cosmosdb list --output table

Cosmos DB - list databases without Automatic Failover

az cosmosdb list --query "[?!enableAutomaticFailover].{AccountName:name, Failover:enableAutomaticFailover}" --output table

Save CLI output as JSON

az cosmosdb list -o json | Out-File -Path "C:\database.json"