Azure Classroomnotes 19/Mar/2023

Azure Compute Workshop

Context

  • 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
      Preview
  • 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
    Preview
  • 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
Get-Process
$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
    Preview
  • Create an ubuntu 18 vm and windows 2016 vm
  • Lets create Azure Automation Account Refer Here
  • Patching Azure VMS Refer Here

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

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

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube