In short: Yes, you can upsize existing disks. The maximum size is 1 TB. To downsize, you need to create a smaller disk and copy the data across.

Here is how it is done

The process is different for ARM and Classic VMs. In both cases, having either Azure PowerShell or the Azure CLI installed is a requirement. The instructions are provided for Azure PowerShell.

You can download Azure PowerShell by following this link: https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/

If you are starting a new session, you need to log into Azure PowerShell, before you can use the module:

# for classic
Add-AzureAccount
Select-AzureSubscription -SubscriptionId "Your Subscription Id"

# for ARM
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId "Your Subscription Id"

Before you start, please ensure that you have a backup of your machine.
The process will incur some downtime. You may want to schedule a maintenance window, if your VM is a production workload.

Changing disk sizes on Classic VMs

In the classic deployment model, we have virtual disk objects that encapsulate the actual VHD files stored in the virtual machine’s storage account.

If you want to find out the name of a disk or several disks that is/are currently attached to an Azure Classic VM, you can run the following set of commands:

# shows the OS disk name
Get-AzureVM -ServiceName <Your Cloud Service Name> -Name <Your VM Name> | Get-AzureOSDisk

# shows the data disk name(s)
Get-AzureVM -ServiceName <Your Cloud Service Name> -Name <Your VM Name> | Get-AzureDataDisk

Once we have the name of the disk that we are trying to resize, we need to run the following PowerShell.

# stop the machine
Stop-AzureVM -Name “Your VM Name” -ServiceName “Your Cloud Service Name”

# change the disk size
Update-AzureDisk -DiskName "Disk name from the Get-AzureDataDisk output" -Label Resized -ResizedSizeInGB “NEW_SIZE_IN_GB_MAX_1TB”

# restart the machine
Start-AzureVM -Name “Your VM Name” -ServiceName “Your Cloud Service Name”

Classic Machine - before disk resize
Classic Machine – before disk resize

 

PowerShell to resize classic disks
PowerShell to resize classic disks

 

Classic machine; after disk resize
Classic machine – after disk resize

 

Changing disk sizes on ARM VMs

We first need to get the VM configuration by running the following command:

$vm = Get-AzureRmVM -Name "Your VM Name" -ResourceGroupName "Resource Group Name for the VM"
$vm.StorageProfile.DataDisks shows a list of all data disks, while $vm.StorageProfile.OSDisk shows more information on the OS disk.

 

Exploring data disks of an ARM machine in PowerShell
Exploring data disks of an ARM machine in PowerShell

 

We can increase the size of each disk simply by editing the SizeInGB parameter while the machine is turned off. A VM update is required.

 

# shut the VM down
Stop-AzureRMVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName

# change OS disk to 256 gb in size
$vm.StorageProfile.OsDisk.DiskSizeGB = 256

# change data disk at LUN 0 to 1 TB
$vm.StorageProfile.DataDisks[0].DiskSizeGB = 1023

# VM update - required
Update-AzureRMVM -VM $vm -ResourceGroupName $vm.ResourceGroupName

# restart VM
Start-AzureRmVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName

ARM machine - before disk resize
ARM machine – before disk resize
ARM machine - after disk resize
ARM machine – after disk resize

After changing the disk size

Once the disk size has been changed we still need to adjust the volume size inside the VM.