Sunday, August 16, 2015

Resize Azure VM OS or Data Disk

Resizing an Azure VM disk using Update-AzureDisk -ResizedSizeinGB

Resizing an Azure VM disk was only possible until recently by using third party software such as Cloud Xplorer using a multistep approach. Not ideal. Best practice says provision Azure disk at maximum capacity but for one of my customers I faced the challenge where I migrated VMs using Azure Site Recovery. ASR is a great tool but it provisioned the target VMs with disks that match the size of the source, and it doesn't provide the option to change this. Now what if I run out of space? Or what if I don't want a 30 GB OS volume, but the 127 GB default size.

To overcome this problem I searched and found the following article. Azure Linux VM - Resize root volume. Great article, but it's only covers OS disks and Linux. The article includes a new command which hasn't been documented on MSDN yet. Which is Update-AzureDisk -ResizedSizeinGB

In my case I'm dealing with Azure VMs that run the Windows OS, and in many cases it's not only the OS disk that needs to be resized, but also the data disk.

I tested both scenario's and can confirm the Update-AzureDisk -ResizedSizeinGB works on both OS and data disks. In this article I'll explain how to use the command to resize Azure VM disks.

Note: The disk cannot be in use, shutdown the VM prior to making this change. And it cannot be reversed. You can only increase the size, the command will not allow you to shrink. 

The command

The command is pretty straight forward and all you need is to be a co-administrator and running the latest AzurePowerShell cmdlet. The command itself is as follow. 

Update-AzureDisk -DiskName 'MyDiskName' -Label 'MyLabel' -ResizedSizeInGB 300

Changing the disk size Step-by-Step


The Azure VM OS disk resize

1. First of all we'll connect to the subject VM and check out it's OS disk size. In this case it's a standard Azure VM with a 127GB disk. It can of course also be a much smaller disk which is in desperate need of resizing.

Azure VM OS Disk - 127 GB


2. De-allocate the Azure VM. The disks cannot be in use at the time of the resize.

3. Connect to your subscription using the latest Azure PowerShell cmdlet. 

4. To resize the disk you'll require the Diskname. To retrieve this information, in my case of VM ate-azr400, run the following command. If you want to make your life easy, store this information in a variable.
Get-AzureVM -ServiceName ate-azr4 -Name Ate-azr400 | Get-AzureOSDisk


Retrieve Azure VM DiskName


5. Run the following command to resize the disk. This will take a few second so be patient while the resize takes place.
Update-AzureDisk -DiskName ate-azr400-ate-azr400-0-201502180257360595 -Label Resized -ResizedSizeInGB 300


Update-AzureDisk -ResizedSizeinGB


6. Now have a look in the portal and browse to the container where the OS disk is stored. You'll find that the VHD has increased from the former 127 GB to 300 GB.

New size in Portal


7. Power On the Azure VM, and open the disk management to view the changes that have been applied. If you require the space extend your volume.

Resized VM OS Disk - 300 GB


The Azure VM Data Disk Resize

To resize the Azure VM Data Disk you pretty much follow the same process. The only difference is the command used to retrieve the Azure Disk Name.

1. To resize Azure Data Disk you'll require the Diskname. Note that this time I run Get-AzureDataDisk. In this case I want to extend the 10 GB disks.
Get-AzureVM -ServiceName ate-azr4 -Name Ate-azr400 | Get-AzureDataDisk


Get-AzureDataDisk


2. Next I run the same Update-AzureDisk -ResizedsizeinGB cmdlet to resize the Azure VM Data disk. This time I run it with the other DiskName.  
Update-AzureDisk -DiskName ate-azr400-ate-azr400-1-201505171031360397 -Label ResizeDataDisk -ResizedSizeInGB 150

Resize Azure VM Data Disk


3. If I now retrieve the information again I'll find that the disk size has been updated to 150 GB. 

Resized to 150 GB.

4. Power On the VM again and review the changes. You should find that the disk has now changed to 150 GB.

Disk size increased to 150 GB

Sunday, August 2, 2015

Change Windows 2012 R2 Server Edition without Re Installing Windows from Media

Just started a new project today for a customer where I will be building a 2 node DAG on Server 2012.
Got the Exchange server bits installed and then tried creating the DAG which failed.
After a bit of analysis it transpires that the customer built the base OS with Windows 2012 Standard and not DataCenter (Server 2012 doesn’t include an Enterprise Edition any more)
Luckily we can convert between editions of Windows Server on the fly via DISM (Deployment Image Service & Management)
TechNet documentation on converting between server 2012 versions can be found here
To determine the current edition of Windows Server installed run the following
  • DISM /online /Get-CurrentEdition
image
To determine which versions the server can be upgraded to run
  • DISM /online /Get-TargetEditions
image
As can be seen from the above screenshot this version of Windows Server can be upgraded toTarget Edition : ServerDatacenter
To complete the conversion between editions we use the DISM command with the following format
  • DISM /online /Set-Edition:<Version> /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /AcceptEULA
In the above example the target edition is ServerDatacenter
image
A reboot of the server and a check of the server edition reveals that is has indeed been successfully upgraded to DataCenter
image