Demo

Subscription

Create a new Resource Group

EntraID

Create a VM https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-portal Azure CLI

https://learn.microsoft.com/en-us/cli/azure/install-azure-cli

az group list --output table

# Create a new Resource Group
az group create --name resgroup_via_cli --location eastus2

# delete the Resource Group
az group delete --name resgroup_via_cli 

# Delete the Resource Group without Prompt
az group delete --name resgroup_via_cli -y

# Managing Virtual Machines:

# List all VMs.

az vm list

# Azure List Sizes

az vm list-sizes --location eastus

az vm list-sizes --location eastus --output table

az vm list-sizes --location eastus --query "[].{AccountName:name, Cores:numberOfCores}" --output table

az vm list-sizes --location eastus | jq -r 'sort_by([.numberOfCores,.maxDataDiskCount]) | .[] | "\(.name) \(.numberOfCores) \(.memoryInMB)MB \(.osDiskSizeInMB)MB \(.resourceDiskSizeInMB)MB \(.maxDataDiskCount)"'


az vm create --resource-group resgroup_via_cli --name myubuntu --image Ubuntu2204 --generate-ssh-keys

az vm show --resource-group resgroup_via_cli --name myubuntu --query "{username:osProfile.adminUsername}" --output tsv 

az vm list-ip-addresses --resource-group resgroup_via_cli --name myubuntu

az vm show --resource-group resgroup_via_cli --name myubuntu --query "hardwareProfile.vmSize" --output tsv


#Start a VM: 

az vm start --resource-group resgroup_via_cli --name myubuntu

Stop a VM: 

az vm stop --resource-group resgroup_via_cli --name myubuntu


#Deallocate a VM

az vm deallocate --resource-group resgroup_via_cli --name myubuntu

az vm resize -g resgroup_via_cli -n myubuntu --size Standard_DS3_v2


Resize all VMs in a resource group.

az vm resize --size Standard_DS3_v2 --ids $(az vm list -g resgroup_via_cli --query "[].id" -o
        tsv)

Delete a VM

az vm delete --resource-group resgroup_via_cli --name myubuntu


Storage

az storage account list -g gc-resourcegroup --output table

az storage account list --resource-group gc-resourcegroup --query "[].{AccountName:name, Location:location}" --output table


az storage account show-connection-string --name gcstorage007 -g gc-resourcegroup

Create a storage account:

az storage account create --name newstorage --resource-group MyResourceGroup --location eastus --sku Standard_LRS

Last updated