Automating switch between Standard HDD and Premium Disk on VMs

KindCompute-6524 85 Reputation points
2024-07-22T06:46:23.98+00:00

How can we have an automation that changes our VM's disk type to Standard HDD when we turn them off and then changes them to Premium before turning the VM back on? Is there any ready-to-use method available?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,588 questions
Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
603 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,196 questions
Azure Automanage
Azure Automanage
An Azure service that simplifies and optimizes the management of virtual machines with automated operations.
1 question
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,332 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Prrudram-MSFT 23,211 Reputation points
    2024-07-23T07:38:15.82+00:00

    Hi @KindCompute-6524

    Thank you for reaching out to the Microsoft Q&A platform.

    Unfortunately, there is no ready-to-use method available for this specific scenario. However, this doesn't sound practical to keep switching the disk type between standard and premium each time the VM is not in use. If this is to save costs and you have the backup of the VMs. You can use Azure PowerShell to automate the process of changing the disk type of your VMs. You can create a PowerShell script that turns off the VM, changes the disk type to Standard HDD, turns the VM back on, and then changes the disk type to Premium.

    You can use the Stop-AzVM and Start-AzVM cmdlets to turn off and on the VM, respectively. You can use the Update-AzDisk cmdlet to change the disk type.Ref: https://learn.microsoft.com/en-us/powershell/module/az.compute/update-azdisk?view=azps-12.1.0

    https://learn.microsoft.com/en-us/powershell/module/az.compute/start-azvm?view=azps-12.1.0

    If I have answered your query, please click "Accept as answer" as a token of appreciation

    0 comments No comments