Thursday, March 8, 2018

Resize OS disk or datadisk - Azure SystemAdminLab4

Good day All,

Welcome back!!!

With we system admin so used to expanding or resizing disk on the fly this would be odd to see that you need to shutdown the VM to perform disk expansion in cloud and it needs downtime.

As things changes i think we will these little things getting fixed for now below is the steps and this can be possible on using power shell

One more point is these disk are Managed disk scroll down below steps to do UnManaged disk
Information you need is :

1.Name of the Virtual Machine
2.Resource group name the Virtual Machine is residing


























it will ask if you want to use Bash Shell or Powershell , then it will authenticate to you subscription
and something like will open
























In the below example i am expanding OS disk from 128 GB to 135 GB


















PS Azure:\> $rgName = 'SystemLabSeries'   - Resource Group Name

PS Azure:\> $vmName = 'FooAzureVM1'    - Virtual Machine

PS Azure:\> $vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName

PS Azure:\> Stop-AzureRMVM -ResourceGroupName $rgName -Name $vmName

Virtual machine stopping operation
This cmdlet will stop the specified virtual machine. Do you want to continue?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y


OperationId :
Status      : Succeeded
StartTime   : 3/8/2018 1:27:33 PM
EndTime     : 3/8/2018 1:29:44 PM
Error       :

PS Azure:\> $disk= Get-AzureRmDisk -ResourceGroupName $rgName -DiskName $vm.StorageProfile.OsDisk.Name

PS Azure:\> $disk.DiskSizeGB = 135

PS Azure:\> Update-AzureRmDisk -ResourceGroupName $rgName -Disk $disk -DiskName $disk.Name


ResourceGroupName  : SystemLabSeries
ManagedBy          : /subscriptions/fe0e7be8-12b6-4f07-9198-408138129742/resourceGroups/SystemLabSeries/providers/Microsoft.Compute/virtualMachines/FooAzureVM1
Sku                : Microsoft.Azure.Management.Compute.Models.DiskSku
Zones              :
TimeCreated        : 3/7/2018 6:47:11 AM
OsType             : Windows
CreationData       : Microsoft.Azure.Management.Compute.Models.CreationData
DiskSizeGB         : 135
EncryptionSettings :
ProvisioningState  : Succeeded
Id                 : /subscriptions/fe0e7be8-12b6-4f07-9198-408138129742/resourceGroups/SystemLabSeries/providers/Microsoft.Compute/disks/FooAzureVM1_Os Disk_1_80ff944c93b34895a4d67caa2b014c52

Name               : FooAzureVM1_OsDisk_1_80ff944c93b34895a4d67caa2b014c52
Type               : Microsoft.Compute/disks
Location           : southindia
Tags               : {}


PS Azure:\> Start-AzureRmVM -ResourceGroupName $rgName -Name $vmName


OperationId :
Status      : Succeeded
StartTime   : 3/8/2018 1:37:59 PM
EndTime     : 3/8/2018 1:39:51 PM
Error       :

If you see below successfully expanded the drivers.
























So if you have to do this example of a datadisk then steps are same just the below changes, you need to mention Data Disks[0] , 1 2 etc..

$disk= Get-AzureRmDisk -ResourceGroupName $rgName -DiskName $vm.StorageProfile.DataDisks[0].Name


UnManaged disk:

Steps pretty much the same for OS disk

$rgName = 'my-resource-group-name' $vmName = 'my-vm-name' $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

Un Managed datadisk : you just change from OSDisk to DataDisk[0]

$vm.StorageProfile.DataDisks[0].DiskSizeGB = 1023

We come to end of this one, until next one you all have a good day!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

4 comments: