Skip to content

Instantly share code, notes, and snippets.

@blark
Last active July 12, 2018 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blark/a21f9677196f137506a082ad379e5edd to your computer and use it in GitHub Desktop.
Save blark/a21f9677196f137506a082ad379e5edd to your computer and use it in GitHub Desktop.
Powershell to Convert disk to StandardSSD_LRS in Azure
$diskName = 'yourDiskName'
$rgName = 'yourResourceGroupName'
$storageType = 'StandardSSD_LRS'
$disk = Get-AzureRmDisk -DiskName $diskName -ResourceGroupName $rgName
# Get parent VM resource
$vmResource = Get-AzureRmResource -ResourceId $disk.ManagedBy
# Stop and deallocate the VM before changing the storage type
Stop-AzureRmVM -ResourceGroupName $vmResource.ResourceGroupName -Name $vmResource.Name -Force
$vm = Get-AzureRmVM $vmResource.ResourceGroupName -Name $vmResource.ResourceName
# Update the storage type
$diskUpdateConfig = New-AzureRmDiskUpdateConfig -AccountType $storageType -DiskSizeGB $disk.DiskSizeGB
Update-AzureRmDisk -DiskUpdate $diskUpdateConfig -ResourceGroupName $rgName `
-DiskName $disk.Name
Start-AzureRmVM -ResourceGroupName $vm.ResourceGroupName -Name $vm.Name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment