Skip to content

NKCODE TECH GEEK ZONE

  • RSS - Posts
Menu
  • Home
  • Cloud
    • Azure
    • Alibaba
    • AWS
  • Hardware
  • Linux
  • Network
  • Security
  • Windows Client / Servers
    • SQL
    • Windows Client OS
      • Windows 10
    • Windows Servers
      • Windows 2008R2
      • Windows Server 2012R2
      • Windows Server 2016
      • Windows Server 2019
  • VMWARE
  • Free Tools
  • About Me
    • Disclaimer
Menu

Resize an Azure Virtual Machine in an Availability Set Using PowerShell

Posted on July 14, 2021

Using Cloud Shell PowerShell to do you identify the VMs with low CPU utilization and change their size Over Cost Virtual Machine (VM).

Log in to the Azure portal using the credentials provided on the lab page.

  • Start Cloud Shell
  • Click the Cloud Shell icon (>_) in the upper right.
  • Select PowerShell.
  • Click Show advanced settings.
  • For Storage account, select Create new and give it a globally unique name (e.g., “nkcodecloudshell” with a series of numbers at the end).
  • For File share, select Create new and give it a name of “fileshare”.
  • Click Create storage.

Get the VM Size and CPU Metrics

Find the current size of the VMs:

Get-AzVM

Get the VM subscription name:

Get-AzSubscription

Check VM CPU metrics, replacing <ID> with the VM subscription name and <RESOURCE_GROUP_NAME> with the group name you just copied:

az monitor metrics list –resource /subscriptions/<ID>/resourceGroups/<RESOURCE_GROUP_NAME>/providers/Microsoft.Compute/virtualMachines/labVM0

Resize VMs in the Availability Set

Assign the value to the $vm variable:

$vm = Get-AzVM -ResourceGroupName <RESOURCE_GROUP_NAME> -VMName labVM0

Perform the PowerShell commands to resize the VM(s):

$vm.HardwareProfile.VmSize = “Standard_B1s”

Update-AzVM -VM $vm -ResourceGroupName <RESOURCE_GROUP_NAME>

To view results of the change, enter Get-AzVM. We should see VMSize for labVM0 changed to Standard_B1s.

Share this:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Reddit (Opens in new window) Reddit
  • Email a link to a friend (Opens in new window) Email

Like this:

Like Loading…

Related

Welcome to Teck Geek Zone

Alibaba & Azure Cloud with a free trial worth $200-1200 USD Click below Cloud Providers

  • How to Configure Multi-Pool Point-to-Site (P2S) VPN Using Azure Virtual WAN (vWAN)
  • 🔐 IoT Security with AWS IoT: Building Secure Connected Systems at Scale
  • Azure Service Endpoint vs Private Endpoint: What’s the Difference and When to Use Each?
  • Amazon Inspector Code Security: Shifting Left with Automated Vulnerability Detection
  • Azure Introduces Network Security Hub: A Smarter Way to Secure Your Cloud Network

Categories

  • Cloud (200)
    • Alibaba (39)
    • AWS (45)
    • Azure (122)
  • Free Tools (5)
  • Hardware (17)
  • Linux (13)
  • Network (28)
  • Security (21)
  • VMWARE (58)
  • Windows OS (44)
    • Windows 10 (7)
  • Windows Servers (69)
    • SQL (3)
    • Windows 2008R2 (7)
    • Windows Server 2012R2 (15)
    • Windows Server 2016 (20)
    • Windows Server 2019 (10)

Subscribe to our newsletter

©2026 NKCODE TECH GEEK ZONE | Design: Newspaperly WordPress Theme

Loading Comments...

    %d