The Azure command-line interface (Azure CLI) is a set of commands used to create and manage Azure resources. The Azure CLI is available across Azure services and is designed to get you working quickly with Azure, with an emphasis on automation.
You can either download Azure CLI on your system (Microsoft installer). You can get it for Microsoft, Linux, MacOS or even Docker.
Another way to access it is using Cloud Shell from Azure portal and choose Bash mode.
You can then issue command as follows
Azure CLI interactive mode places you in an interactive shell with auto-completion, command descriptions, and examples.
az interactiveHere are some of the commands to get you started.
az loginaz login -u myemail@address.comaz account listaz account set --subscription "xxx"
OR
az account set -s "xxx"az account list-locationsaz resource listazure --version
azure help
az vm list-sizes --location eastusaz account list-locations -o tableaz vm image list --output tableaz vm create --resource-group myResourceGroup --name myVM --image ubuntults
az vm create --resource-group myResourceGroup --name myVM --image win2016datacenter
az group create --name myresourcegroup --location eastusaz group list -o tableaz storage account create -g myresourcegroup -n mystorageaccount -l eastus --sku Standard_LRS
az group delete --name myResourceGroup
az vm listaz vm start --resource-group myResourceGroup --name myVMaz vm stop --resource-group myResourceGroup --name myVMaz vm deallocate --resource-group myResourceGroup --name myVM
az vm restart --resource-group myResourceGroup --name myVMaz vm redeploy --resource-group myResourceGroup --name myVMaz vm delete --resource-group myResourceGroup --name myVMaz image create --resource-group myResourceGroup --source myVM --name myImageaz vm create --resource-group myResourceGroup --name myNewVM --image myImage
az vm extension list --resource-group azure-playground-resources --vm-name azure-playground-vmaz vm extension delete --resource-group azure-playground-resources --vm-name azure-playground-vm --name bootstrapperaz batch account create -g myresourcegroup -n mybatchaccount -l eastus
az storage account create -g myresourcegroup -n mystorageaccount -l eastus --sku Standard_LRS
az batch account set -g myresourcegroup -n mybatchaccount --storage-account mystorageaccount
We can now authenticate directly against the account for further CLI interaction.
az batch account login -g myresourcegroup -n mybatchaccount
az batch account show -g myresourcegroup -n mybatchaccount
az batch application create --resource-group myresourcegroup --name mybatchaccount --application-id myapp --display-name "My Application"
az batch application package create --resource-group myresourcegroup --name mybatchaccount --application-id myapp --package-file my-application-exe.zip --version 1.0
az batch application set --resource-group myresourcegroup --name mybatchaccount --application-id myapp --default-version 1.0
az batch pool node-agent-skus list
az batch pool create \
--id mypool-linux \
--vm-size Standard_A1 \
--image canonical:ubuntuserver:16.04.0-LTS \
--node-agent-sku-id “batch.node.ubuntu 16.04”
az batch pool resize --pool-id mypool-linux --target-dedicated 5
az batch pool show --pool-id mypool-linux
az batch node list --pool-id mypool-linux
If a particular node in the pool is having issues, it can be rebooted or reimaged. A typical node ID will be in the format 'tvm-xxxxxxxxxx_1-'.
az batch node reboot --pool-id mypool-linux --node-id tvm-123_1-20170316t000000z
az batch node delete \
--pool-id mypool-linux \
--node-list tvm-123_1-20170316t000000z tvm-123_2-20170316t000000z \
--node-deallocation-option requeue
az batch job create --id myjob --pool-id mypool
…where is your preferred shell for execution (/bin/sh, /bin/bash, /bin/ksh etc.), and /path/to/script.sh is, of course, the full path of the shell script you’re invoking to get things started.
az batch task create --job-id myjob --task-id task1 --application-package-references myapp#1.0 --command-line "/bin/<shell> -c /path/to/script.sh"
az batch task create --job-id myjob --json-file tasks.json
Now that all the tasks are added - we can update the job so that it will automatically be marked as completed once all the tasks are finished.
az batch job set --job-id myjob --on-all-tasks-complete terminateJob
az batch job show --job-id myjob
az batch task show --job-id myjob --task-id task1
az batch job delete --job-id myjob
If you HAVE AN SSH run this to create an Azure Container Service Cluster (~10 mins)
az acs create -n acs-cluster -g acsrg1 -d applink789
If you DO NOT HAVE AN SSH run this to create an Azure Container Service Cluster (~10 mins)
az acs create -n acs-cluster -g acsrg1 -d applink789 --generate-ssh-keysaz acs list --output tableaz acs list -g acsrg1 --output table
az acs show -g acsrg1 -n acs-cluster --output listaz acs scale -g acsrg1 -n acs-cluster --new-agent-count 4az acs delete -g acsrg1 -n acs-cluster
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.