Tuesday, January 3, 2017

How to Resize/Expand Windows Azure VM OS Disk

 

Here I'm going to show the steps that you can follow to expand your Azure VM Operating system Disk.  
There are a couple of ways to do this and here I'm using the PowerShell to do the work .    
 
First, you can try to run the below command on your PowerShell and check whether you can connect to your Microsoft Azure account in resource management (ARM) mode. 
 
PS C:\Windows\system32> Login-AzureRmAccount
 
If this doesn't give an Azure portal sign-in window, then first you have to install the ARM or the latest version of the 
Azure powershell from the   Gallery using an elevated Windows PowerShell. (ARM installation steps will post in the next post)   
 
Then you can test the Azure connectivity  by typing below command, 
 
PS C:\Windows\system32> Login-AzureRmAccount

PS Logi n—AzureRmAccount

If you can get the below mentioned windows means, you can go into the next step.

Sign in to your account 
Microsoft Azure 
Work or school, or personal Microsoft account 
hemale@yahoo.com 
Password 
Sign in 
Can't access your account? 
x

PS Logi n—AzureRmAccount 
Environment 
Accou nt 
Tenantld 
Subscr i pt i onld 
Subscr i pt i onName 
CurrentStor ageAccount 
PS 
: Azur«loud 
. Visual Studio Enterprise

If you are using PowershellISE then this will be easy for you to run the below script. Copy and paste the below script and  Copy and paste the correct values for

Name_of_the_Azure_subscription, Name_of_the_Resource_Group, Name_of_the_Server and give the correct capacity for the OS Disk.

Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionName 'Name_of_the_Azure_subscription'
$rgName = 'Name_of_the_Resource_Group'
$vmName = 'Name_of_the_Server'
$vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName
Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName
$vm.StorageProfile.OSDisk.DiskSizeGB = 1023
Update-AzureRmVM -ResourceGroupName $rgName -VM $vm
Start-AzureRmVM -ResourceGroupName $rgName -Name $vmName

Untitledl.psl* X 
4 
Log i n —Azur eRmAccount 
Sel ect—AzureRmSubscription —Subscripti onName 'Visual Studio Enterprise' 
SrgName 
Server ' 
SvmName 
'WIn2016DC' 
Svm 
SrgName -Name 
SvmName 
Get-AzureRmVN -ResourceGr oupName 
Stop-AzureRmVM —ResourceGroupName SrgName -Name 
SvmName 
Svm Storageprofile. OSDiskL DiskSizeG8 = 1023 
Update—AzureRmW -ResourceGroupName 
Sr g Name —VY Svm 
SrgName -Name 
SvmNamel 
Start—AzureRmVM -ResourceGroupName

You can download this from here.

Once you run the Script, It will ask for the credentials. Give that and hit Sign in.

Sign in to your account 
Microsoft Azure 
Work or school, or personal Microsoft account 
hemale@yahoo.com 
Password 
Sign in 
Can't access your account? 
x

This information window will pop up and you can hit yes.

Virtual machine stopping operation 
This cmdlet will stop the specified virtual machine. Do you want to continue?

PS Logi n—AzureRmAccount 
Select—AzureRmSubscription -SubscriptionName 'Visual Studio Enterprise' 
Sr gName 
Server ' 
SvmName 
• Win 2016DC 
Svm = Get-AzureRmW —ResourceGroupName SrgName SvmName 
Stop-AzureRmW —ResourceGroupName SrgName —Name SvmName 
Svm. StorageProfi le. OSDisk.DiskSizeG8 = 1023 
Update—AzureRmW -ResourceGroupName -W' Svm 
Start—AzureRmW SrgName —Name SvmName 
Environment 
Accou nt 
Tenantld 
Subscr i pt i onld 
Subscr i pt i onName 
CurrentStor ageAccount 
: Azur«loud 
. Visual Studio Enterprise 
Account 
Environment 
Subs cri pt ion 
Tenant 
: Azur«loud 
WARNING: Breaking change notice: In 
n Storageprofile and Networkprofile, 
upcoming releaese, 
respectively. 
top level properties, 
DataDiskNames and NetworkInterfaceIDs , 
will 
be renoved from VY object because they are also i

Once the task completed, you will get the below "Succeeded" alert with the Start, Stop time.

Operati onld : 
. Succeeded 
Status 
Start Ti me 
: 03/01/2017 14:57:58 
EndTime 
: 03/01/2017 14:58:00 
Er ror

Connect into your VM and go into "Disk Management". You will see the Unallocated space. From there you will be able to extend the OS Disk.

Computer Management 
File Action View Help 
Computer Management (Local 
System Tools 
Task Scheduler 
Event Viewer 
Shared Folders 
Local Users and Groups 
Performance 
Device Manager 
Storage 
Windows Server 
Disk Management 
Services and Applications 
Volume 
Temporary Storage (D:) 
out 
Simple 
Simple 
Basic 
Basic 
File 
NTFS 
NTFS 
em 
Status 
Healthy (System, Boot, Active, Crash Dump, Primary 
Healthy (Page File, Primary Partition) 
Basic 
102300 
Online 
Basic 
700 
Online 
12700 G8 NTFS 
Healt (System, Boot, Active, Crash D 
Temporary Storage (D:) 
700 NTFS 
Healthy (Page File, Primary Partition) 
8-9600 
Unallocated 
Unallocated Primary partition

Hope this helps you to expand  your Azure VM OS Disk.

No comments: