UPDATE (09SEP2013): There's a faster way.  See: https://github.com/maartenba/WindowsAzureDiskResizer

I got into a bit of a predicament where the C drive of the VM I created here started to fill up.  I needed to install some software that only gave me the option to install to the C drive.  The installer was telling me there wasn’t enough disk space.  Here’s what I did to increase the size of the OS disk of my Azure VM:

  • Delete the VM
  • Download the .vhd
  • Resize the downloaded .vhd
  • Delete the original .vhd from blob storage
  • Upload the resized .vhd
  • Recreate the VM
  • Use diskpart to get access to the unallocated part of C

Delete the VM

image

Download the .vhd

Cloud Storage Studio is my favorite storage tool for Windows Azure.  If you’d prefer a free option, then my next favorite is Azure Storage Explorer.  Use one of these to download the .vhd file.  This part is going to require a local hard drive with lots of disk space.  You will need at least 2x the size of the original VHD + the size you want to grow it by.  A fast internet connection will be a big advantage here as well.

Resize the downloaded .vhd

You can use Hyper-V Manager to resize your .vhd file:

image

My challenge was that the PC with the disk space necessary to store the downloaded and expanded .vhd wasn’t Hyper-V capable.  Therefore, I used a tool called VHD Resizer from here.  There is a nice walkthrough of how to use it here.

Delete the original .vhd from blob storage

image

Upload the resized .vhd

You need to upload the resized .vhd back to blob storage.  I figured out how to upload it correctly after reviewing Step 5 from the Creating and Uploading a Virtual Hard Disk that Contains the Windows Server Operating System instructions.  However, the command line switches for csupload.exe need to look like this:

csupload Add-Disk –Destination “<full blob url you want for your vhd>” –Label “<whatever you want>” –LiteralPath “<path to resized .vhd>” –OS Windows

Recreate the VM

I created a new VM via the management portal and pointed it to the .vhd file I uploaded with csupload.  In my case, I had to re-attach an additional .vhd drive since my original .vhd was configured with an F drive where my database files were stored.  Once your VM boots up, log in using Remote Desktop.  For me, all of my SQL Server 2012 databases were in a recovering state.  Not sure why.  After I rebooted my server, everything was fine. 

Use diskpart to get access to the unallocated part of C

Your C drive will still report the old size in Windows Explorer.  You need to claim the additional unallocated space in the expanded drive.  To do this, open a command prompt and execute the following series of commands in italics:

diskpart

Next execute:

list disk

Make sure you select the os disk.  For me, it was disk 0:

select disk=0

Find the partition that needs extending:

list partition

Select the partition.  For me, it was partition 1:

select partition=1

Finally, extend the partition:

extend

Now, you have the additional space in the drive you need to install more stuff Smile.

@devkeydet