Skip to content

Commit 7190d7c

Browse files
authored
Merge pull request #42559 from kwill-MSFT/patch-8
Fix Update-AzDisk to not be destructive
2 parents 29d6408 + f3fefbd commit 7190d7c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

articles/virtual-machines/windows/convert-disk-storage.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ foreach ($disk in $vmDisks)
5858
{
5959
if ($disk.ManagedBy -eq $vm.Id)
6060
{
61-
$diskUpdateConfig = New-AzDiskUpdateConfig –AccountType $storageType
62-
Update-AzDisk -DiskUpdate $diskUpdateConfig -ResourceGroupName $rgName `
63-
-DiskName $disk.Name
61+
$disk.Sku = [Microsoft.Azure.Management.Compute.Models.DiskSku]::new($storageType)
62+
$disk | Update-AzDisk
6463
}
6564
}
6665
@@ -97,9 +96,8 @@ $vm.HardwareProfile.VmSize = $size
9796
Update-AzVM -VM $vm -ResourceGroupName $rgName
9897
9998
# Update the storage type
100-
$diskUpdateConfig = New-AzDiskUpdateConfig -AccountType $storageType -DiskSizeGB $disk.DiskSizeGB
101-
Update-AzDisk -DiskUpdate $diskUpdateConfig -ResourceGroupName $rgName `
102-
-DiskName $disk.Name
99+
$disk.Sku = [Microsoft.Azure.Management.Compute.Models.DiskSku]::new($storageType)
100+
$disk | Update-AzDisk
103101
104102
Start-AzVM -ResourceGroupName $vm.ResourceGroupName -Name $vm.Name
105103
```
@@ -142,9 +140,8 @@ Stop-AzVM -ResourceGroupName $vmResource.ResourceGroupName -Name $vmResource.Nam
142140
$vm = Get-AzVM -ResourceGroupName $vmResource.ResourceGroupName -Name $vmResource.Name
143141
144142
# Update the storage type
145-
$diskUpdateConfig = New-AzDiskUpdateConfig -AccountType $storageType -DiskSizeGB $disk.DiskSizeGB
146-
Update-AzDisk -DiskUpdate $diskUpdateConfig -ResourceGroupName $rgName `
147-
-DiskName $disk.Name
143+
$disk.Sku = [Microsoft.Azure.Management.Compute.Models.DiskSku]::new($storageType)
144+
$disk | Update-AzDisk
148145
149146
Start-AzVM -ResourceGroupName $vm.ResourceGroupName -Name $vm.Name
150147
```

0 commit comments

Comments
 (0)