You may follow this process, but please be careful, as mistakes may lead to data loss:
- The first step is to add a new disk (or more new disks, depending from your scenario) to the virtual machine from the Portal.
- Once the new disks are attached, login to the virtual machine, go on Server Manager\File and Storage Services\Volumes\Storage Pools, right click on the Storage Pool you would like to increase, the one providing the resources for the virtual disk you would like to extend, then add the new disks to that pool.
- Do not extend the virtual disk straight away, and if you really have to do it (e.g. if your virtual disk is full and you need some storage to restart a depending service), leave at least 2 GB per disk from the target.
E.g. if the sum of the target physical disks is 512 GB and that is reached with 2 disks, extend max to 508 GB, that's it:
available physical storage (512 GB) - ( disks (2) * 2 GB)
- Find the UniqueId of the disk to retire using this command on a elevated PowerShell prompt:
Get-PhysicalDisk | select DeviceId, FriendlyName, UniqueId, Size, PhysicalLocation
Look on the Azure portal on which LUN the disk has been attached, match that with the LUN reported on PhysicLocation (towards the end of the report, please don't mix it with the DeviceId at the beginning). You need the UniqueId, which is an hexadecimal number that looks like 6002243673DD16EBB4CF0579AE3A7647.
Give a friendly name to the disk to retire you have identified on the previous step:
Set-PhysicalDisk -UniqueId 6002243673DD16EBB4CF0579AE3A7647 -NewFriendlyName ToRetire
- Retire the disk identified in step 5:
Set-PhysicalDisk -FriendlyName ToRetire -Usage Retired
- being careful to choose the correct storage pool, start the repair job for the virtual disk, to move all the data from the disk to retire to the newly added disk(s):
Get-StoragePool –FriendlyName SQLVMStoragePool1 | Get-Virtualdisk | Repair-VirtualDisk -Asjob
- You may check storage job, probably multiple times, until its completion, with the following command:
Get-StorageJob
Once the storage jobs are completed, it is possible to remove the retired and drained disk(s) from the GUI under Server Manager\File and Storage Services\Volumes\Storage Pools, then Physical Disks. Before removing the disk(s) I usually look at their properties, to ensure that used space should be less than 1 GB (around 750 MB to 850 MB). The corresponding cmdlet is Remove-PhysicalDisk. Please be careful, as per the relevant documentation if sufficient space does not exist in the storage pool to tolerate this removal, this can result in a data loss. In this scenario both the GUI and the cmdlet will warn you. Please read carefully before proceeding.
Once the disk is removed, you can unattach it from the Azure Portal. To find out the LUN of the removed disk run the following command:
Get-PhysicalDisk | where CanPool -eq $true | select DeviceId, FriendlyName, UniqueId, Size, PhysicalLocation | ft
- At the same time, once the disk is removed, feel free to extend the virtual disk to the max (which is a bit more than what calculated above).
If you don't need to retire the pre-existing disk(s), you may follow a shorter and simpler process:
- The first step is to add a new disk (or more new disks, depending from your scenario) to the virtual machine from the Portal.
- Once the new disks are attached, login to the virtual machine, go on Server Manager\File and Storage Services\Volumes\Storage Pools, right click on the Storage Pool you would like to increase, the one providing the resources for the virtual disk you would like to extend, then add the new disks to that pool.
- Extend the virtual disk to the max (or to what you need) consuming the storage added in the storage pool in the previous step.
- being careful to choose the correct storage pool, optionally, you may try to run the repair job for the virtual disk, to attempt to spread the data from the old disk(s) to the newly added disk(s):
Get-StoragePool –FriendlyName SQLVMStoragePool1 | Get-Virtualdisk | Repair-VirtualDisk -Asjob
- You may check storage job, probably multiple times, until its completion, with the following command:
Get-StorageJob
You may find here the full documentation for all Windows Storage Management-specific cmdlets.