Azure Classroomnotes 19/Mar/2023

Azure Compute Workshop


  • For every activity possible, lets try to acheive using Azure CLI and Azure Powershell

Activity 1: Stop the VMs With Tag Env: Dev

  • Lab Setup: Create 3 vms in Azure (free tier)
  • Apply Tag

    • Env=Dev for node1
    • Env=QA for node2
    • Env=UAT for node3
  • First Version: The changes done are Refer Here
  • Improvement 1: donot deallocate if there are no vms found Refer Here
  • Imporvement 2: Lets give option to the user to pass tagname and tag value Refer Here for changes
  • Improvement 3: Created a reusable function for empty arguments passed Refer Here

Activity 2: Try Starting the VM based on tags

Activity 3: Get all the resources with tag Env:Dev

  • az resource list --tag "Env=Dev"
  • if the resource type is VM deallocate and if the resource type is storage account delete
az resource list

Quick Commands

  • Get all the locations
  • Using Azure Cli with bash Refer Here
  • Powershell has cmd-lets which will be in the form of verb-noun
$vms=Get-AzResource -Tag @{ Env='UAT'} -ResourceType 'Microsoft.Compute/virtualMachines'
foreach ($vm in $vms) {

    Write-Host "Stopping Vm in Resource group $vm.ResourceGroupName and name $vm.Name"
    Stop-AzVM -Id $vm.Id

Azure VM Automatic Updates

  • Azure Automation Docs Refer Here
  • Create an ubuntu 18 vm and windows 2016 vm
  • Lets create Azure Automation Account Refer Here
  • Patching Azure VMS Refer Here

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner