Use PowerShell to Resize an Azure Virtual Machine in an Availability Set

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Your company’s finance department explains that the cost of Azure virtual machines (VMs) is over budget. You must find an easy solution to decrease the cost of Azure VMs in your subscription. Using only PowerShell, how do you identify the VMs with low CPU utilization and change their size?

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Start Cloud Shell
  1. Click the Cloud Shell icon (>_) in the upper right.
  2. Select PowerShell.
  3. Click Show advanced settings.
  4. Set the cloud shell region to the same location as the resource group
  5. For Storage account, select Create new and give it a globally unique name (e.g., "cloudshell" with a series of numbers at the end).
  6. For File share, select Create new and give it a name of "fileshare".
  7. Click Create storage.
Get the VM Size and CPU Metrics
  1. Find the current size of the VMs.

  2. Get the VM subscription name.

  3. Check VM CPU metrics.

Resize VMs in Availability Set
  1. Check which VMs are available to resize within the VM hardware cluster.

    1. Perform the PowerShell commands to resize the VM(s).

Additional Resources

There are two virtual machines pre-provisioned with this lab. Log in to the Azure portal and discover if these VMs can be resized.

Open Cloud Shell and get to the PowerShell prompt. Ensure to set the cloud shell region to the same location as the resource group.

Then, view the current VM sizes along with the CPUs consumed.

When you've determined that CPU consumption is low, change the VM to a smaller and cheaper size. This will include checking which VM sizes are available on the hardware cluster where the VM is hosted.

Once you've changed the size of the VM(s), you have completed this lab.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?