How to increase the size of the OS disk and data disk in an Azure VM

Picture Credit:
Almost a year back in the 17th of Sept. 2017, in one of my blog post, I have shown you how to add a disk to the Azure VM without any downtime,If you want to read more about that post you can click here. Today I have received a requirement where I need to expand the existing OS disk and the data disk. I will show you how can we do it with the PowerShell script.

In this requirement, I need to increase the C drive to 256 GB and H drive to 128 GB managed disk. As you can see below the disks are almost full.

To do this first you need to login to your Azure Subscription.

In next step use the following PowerShell commands to store the VM and resource-related information in the variable and later stop the VM.

In this step, you need to store the OS disk details in a variable called $disk and assign the size to 256 GB and update the configuration with the Update-AzureRmDisk command as you can see below

Same steps we need to repeat for the data disk as well where we stored the disk related information in a variable called $disk1, please note DataDisk[0] means the disk which is attached to LUN no. 0

Once it’s done you can start the Azure VM

You can find that the disk size increase is reflecting in the portal.

Now you can log in to windows and go run and type compmgmt.msc, from there go to disk management and click on C drive and click on extend the volume in the drop-down menu.

Once you click on that the extend volume wizard will open and it will extend the volume, the below screenshot is showing this step for the data disk.

In next step click on finish to complete the wizard.

That’s all, you should be able to see the extra space in your disks now. Thanks for reading this post. You have a great day ahead.