You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We love the CLI 💙. Cheatsheet with the most common Microsoft Azure CLI commands with examples.
Each section covers one specific set of resources you can manage with your CLI. Per each section you will find the following information:
Title: The resources set name that you can manage with the CLI
Command: Remember this one. It's the basic thing to start. For instance, az group is all about manage resource groups.
Basic actions: Basic actions you can do in the command. Tip: mentally join command and basic action and you will be at half way to use the CLI to manage the resource.
Examples: Set of examples using that command and the basic actions. First, it is described in human expression what you want to perform and the line after, the command that perform the action. Try to link the way of thinking and the sequence of the command and you will never forget a command again.
Note: In the examples is assumed that all the actions are based on your subscription account.
Manage Resouce Groups
Command:
$ az group
Basic actions:
Command
Description
create
Create a new resource group.
delete
Delete a resource group.
exists
Check if a resource group exists.
list
List resource groups.
show
Gets a resource group..
Examples
Create a resource group called playground in northeurope
$ az group create -l "northeurope" -n "playground"
Does it my resource group called playground exists?
$ az group exists -n "playground"
Give me a list with all my resource group
$ az group list
Show me the resouce group called playground
$ az group show -n "playground"
Delete the group playground and do not give me confirmation
$ az group delete -n "playground" -y
Manage Storage accounts
Command:
$ az storage account
Basic actions:
Command
Description
create
Create a storage account.
delete
Delete a storage account.
check-name
Check if a resource group exists.
list
List resource groups.
show
Gets a resource group..
Examples
Create a storage account group called mystorageaccount in the resource group called playground, in the location northeurope and with store-keeping unit Standard_LRS
Specify which batch account the CLI should wotj with.
Pool command:
$ az batch pool
Basic actions:
Command
Description
create
Create a new pool.
show
Show me the information of certain pool
delete
Delete a pool
Job command:
$ az batch job
Basic actions:
Command
Description
create
Create a new pool.
show
Show me the information of certain pool
Task command:
$ az batch task
Basic actions:
Command
Description
create
Create a new task.
show
Show me the information of certain pool
file list
List all the files created for that task
file download
Download files created for that task
Examples:
Create a batch account group called mybatchaccount in the storage account called mystorageaccountin the resource group called playground and in the location northeurope.
Tell to CLI that I am working with the batch account called mybatchaccount in the resource group called playground. For that, I am sharing the authorization keys with you.
$ az batch account login -n "mybatchaccount" -g "playground" --shared-key-auth
Create a pool with the id myfirstpool with the virtual machine size Standard_A1_V2 with 2 dedicated nodes, using canonical:ubuntuserver:16.04-LTS as OS and with node agent batch.node.ubuntu 16.04
Show me state of creation of my pool with id myfirstpool
$ az batch pool show --pool-id $poolName --query "allocationState"
Create a job with the id myjob in my pool with id myfirstpool
$ az batch job create --id myjob --pool-id "myfirstpool"
Create a task with id myfirsttask in the job with the id myjob and the job consist of execute the following command line: /bin/bash -c 'printenv | grep AZ_BATCH; sleep 90s'
Create an AKS cluster called mykubercluster in the resource group called playground with one node (VM) and create in my local machine the ssh keys to access to it.
$ az aks create -n "mykubercluster" -g "playground" --node-count 1 --generate-ssh-keys
Manage App Service Web App
Command:
$ az webapp
Basic actions:
Command
Description
create
Create a web app resource.
deployment
Show me the information of certain pool
config
List all the files created for that task
Examples:
Create a web app group called mywebapp in the resource group called playground and with the app service plan created before calle myfreeserviceplan.
$ az webapp create -n "mywebapp" -g "playground" --plan "myfreeserviceplan"
Deploy to my web app called mywebapp in the resource group called playground the code that have in github https://github.com/cesiztel/azure-cli-hero based on the master branch and I will manually triggered.