Skip to content

Instantly share code, notes, and snippets.

@hochun836
Last active January 19, 2022 03:13
Show Gist options
  • Save hochun836/73982f4ba84da7c4a62fb1cc837a454c to your computer and use it in GitHub Desktop.
Save hochun836/73982f4ba84da7c4a62fb1cc837a454c to your computer and use it in GitHub Desktop.
# base
az // welcome
az -h // -h <=> --help, there are "Group", "Subgroups", "Commands"
az -v // -v <=> --version
az version // show the versions of azure cli modules and extensions in JSON format by default or format configured by --output
az login // log in to azure
az logout // log out to remove access to azure subscriptions
az account -h // there are "Group", "Subgroups", "Commands"
az account lock -h // there are "Group", "Commands"
az account list -h // there are "Command", "Arguments", "Global Arguments"
az account list // get a list of subscriptions for the logged in account
az account show // get the details of a (default) subscription
az account show -s <subscription-id or subscription-name>
az account show -s "Azure subscription 200" // if name has some space, then need ""
=> ref: https://docs.microsoft.com/en-us/cli/azure/account
# resource
az resource -h
az resource list -h
az resource list // list all resources
az resource list --tag test // list all resources with the tag 'test'
az resource list --tag "test*" // list all resources with a tag that starts with 'test'
az resource list --tag test=example // list all resources with the tag 'test' that have the value 'example'
az resource list --query [].id
az resource list --query [].{id:id}
az resource list --query [].{id:id,name:name}
az resource list --query "[].{id:id, name:name}"
# group (aka. resource group)
az group -h
az group list -h
az group list
az group list -o json // -o <=> --output, default: json
az group list -o table
az group list -o yaml
az group list --query [].id
az group list --query [].id -o table
az group list --query [?location=='southeastasia'] // [?...] is array filter
az group list --query [?location=='southeastasia'].id
# synapse
az synapse -h // manage and operate synapse workspace, spark pool, sql pool
az synapse workspace -h
az synapse workspace list
az synapse workspace show // (--resource-group --name | --ids) are required
az synapse workspace show --resource-group <resource-group-name> --name <workspace-name>
az synapse workspace show --ids <id> [id...]
az synapse sql -h
az synapse sql ad-admin -h
az synapse sql ad-admin show --resource-group <resource-group-name> --workspace-name <workspace-name>
az synapse sql ad-admin show --resource-group rg1102 --workspace-name asa1102
az synapse sql pool -h
az synapse sql pool list --resource-group <resource-group-name> --workspace-name <workspace-name>
az synapse sql pool list --resource-group rg1102 --workspace-name asa1102
az synapse sql pool resume // (--resource-group --workspace-name --name | --ids) are required
az synapse sql pool resume -h
az synapse sql pool resume --ids <id> [id...] // one or more resource ids (space-delimited)
az synapse sql pool pause // (--resource-group --workspace-name --name | --ids) are required
az synapse sql pool pause -h
az synapse sql pool pause --ids <id> [id...] // one or more resource ids (space-delimited)
=> ref: https://docs.microsoft.com/en-us/cli/azure/synapse
=> ref: https://docs.microsoft.com/en-us/cli/azure/synapse/sql/pool?view=azure-cli-latest#az_synapse_sql_pool_pause
# find
az find -h
az find <cli_term> // an azure cli command or group for which you need an example
az find vm
az find synapse
# interactive
az interactive
az>>
ctrl+D // exit
enter // refresh (because interactive mode needs to load something)
# [note] how to install
=> ref: https://docs.microsoft.com/zh-tw/cli/azure/install-azure-cli
# [note] what is JMESPath
JMESPath is a query language for JSON
=> ref: https://jmespath.org/
# [note] how to query azure cli command output using a JMESPath query
=> ref: https://docs.microsoft.com/en-us/cli/azure/query-azure-cli
# [note] azure cli + arm (edited by vscode)
=> ref: https://www.youtube.com/watch?v=SjNnXwrLT1U
# [note] azure cloud shell
=> ref: https://shell.azure.com
# [note] learn
=> ref: https://www.youtube.com/watch?v=GqpwiyYsNIw
# [note] document
=> ref: https://docs.microsoft.com/en-us/cli/azure/
=> ref: https://docs.microsoft.com/en-us/cli/azure/reference-index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment