Monday, 30 August 2021

Azure CLI commands

Get what version of the CLI you have

az --version

Get help

az help


Logging to Azure portal

Login with web

az login

Login in CLI

az login -u myemail@address.com

List accounts

az account list

Set subscription

az account set --subscription "xxx"


Listing locations and resources / general

List all locations

az account list-locations

List all my resource groups

az resource list


Creating a basic VM / Resource Group / Storage Account

Get all available VM sizes

az vm list-sizes --location eastus

Get all available VM images for Windows and Linux

az vm image list --output table

Create a Resource group

az group create --name demo-rg --location eastus2

Create a Linux VM

az vm create --resource-group demo-rg --name myvmfordemo --image ubuntults --admin-username adminazure

Create a Windows VM

az vm create --resource-group demo-rg --name mywindowsvmfordemo  --image win2016datacenter   --admin-username adminazure

Create a Storage account.

az storage account create -g demo-rg -n mystorageaccount -l eastus2 --sku Standard_LRS


DELETING A RESOURCE GROUP

Permanetly deletes a resource group

az group delete --name demo-rg


Managing VM's

List your VMs

az vm list

Start a VM

az vm start --resource-group myResourceGroup --name myVM

Stop a VM

az vm stop --resource-group myResourceGroup --name myVM

Deallocate a VM

az vm deallocate --resource-group myResourceGroup --name myVM

Restart a VM

az vm restart --resource-group myResourceGroup --name myVM

Redeploy a VM

az vm redeploy --resource-group myResourceGroup --name myVM

Delete a VM

az vm delete --resource-group myResourceGroup --name myVM

Create image of a VM

az image create --resource-group myResourceGroup --source myVM --name myImage

Create VM from image

az vm create --resource-group myResourceGroup --name myNewVM --image myImage

List VM extensions

az vm extension list --resource-group azure-playground-resources --vm-name azure-playground-vm

Delete VM extensions

az vm extension delete --resource-group azure-playground-resources --vm-name azure-playground-vm --name bootstrapper

No comments:

Post a Comment