Automating switch between Standard HDD and Premium Disk on VMs

KindCompute-6524 105 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.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Prrudram-MSFT 28,506 Reputation points Moderator
    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

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.