How to switch VM Disk to a lower size to save on cost and keep everything the same

TarekAHF 6 Reputation points
2023-02-19T06:01:29.34+00:00

I moved the VM+Disk and all the related resources from one subscription to another and all is working fine.

It seems I accidentally selected Premium SSD LRS 1024GiB and I see the cost now is multiplied by 6 compared to the previous cost.

I tried to change the size to a lower tier and it is not allowed. I noticed I can only change the size to a higher tier.

I am checking how to change the size to a lower GB such as 128 GB without losing any configuration and data on my disk. I want to maintain the OS and Data on the disk but I want to change the size to 128 GB to save on cost. How?

I am thinking I have to create a snapshot of the disk, detach the disk attached to the VM, delete the VM, and recreate the VM from the saved Snapshot, and this time select the correct disk type. Correct?

Tarek

Azure VMware Solution
Azure VMware Solution
An Azure service that runs native VMware workloads on Azure.
338 questions
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,069 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.
599 questions
{count} votes

2 answers

Sort by: Most helpful
  1. TarekAHF 6 Reputation points
    2023-02-20T08:48:30.2766667+00:00

    I managed to achieve this using DiskGenius free tool. I created Azure Managed Data Disk with the intended performance and size and attached it to the VM as a Data Disk. I then RDP to the VM and installed DiskGenius and used this tool to migrate OS C Drive to the Data Disk (or clone disk). Then, I Disconnected the Data Disk (after cloning) from the VM, and then I used PowerShell 4 command lines to swap the OS disk.

    https://azure.microsoft.com/en-ca/blog/os-disk-swap-managed-disks/

    $vm = Get-AzureRmVM -ResourceGroupName osrg -Name vm2 
    $disk = Get-AzureRmDisk -ResourceGroupName osrg -Name osbackup 
    Set-AzureRmVMOSDisk -VM $vm -ManagedDiskId $disk.Id -Name $disk.Name 
    Update-AzureRmVM -ResourceGroupName osrg -VM $vm
    

    It worked ...

    1 person found this answer helpful.
    0 comments No comments

  2. Sreeju Nair 12,186 Reputation points
    2023-02-19T06:44:26.22+00:00

    Reducing the Disk size through Azure Portal is not supported.

    User's image

    Refer: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/expand-os-disk

    The solution is to use Powershell to shrink the Managed Disk Size.

    https://jrudlin.github.io/2019-08-27-shrink-azure-vm-osdisk/

    https://github.com/jrudlin/Azure/blob/master/General/Shrink-AzDisk.ps1

    The author did a great job of documenting the steps. I recommend you to try it in a test server before applying directly to production.

    Hope this helps