Reputation: 1
Is it possible to replace the OS disk on a Linux Azure Scale Set VM? I'm trying to restore a many node cluster from snapshots where each VM's OS and data disks has unique information. I was able to replace the original data disks by modifying the scale set model to have no data disks, manually updating the individual VMs to the latest model and then adding the recovered data disks to the VM. I have been unsuccessful in modifying the scale set model to have no OS disk (tried updating with empty StorageProfile or StorageProfile.OsDisk sections - no error, but model is unchanged). I also tried copying the snapshot over the os disk, but received a 'Disk xxx not found' error. Is there a way to restore a scale set from snapshots?
Upvotes: 0
Views: 1161
Reputation: 1555
You can take a snapshot of a virtual machine scale set instance and create a managed disk from that snapshot.
Steps to achieve that Azure PowerShell:
Create a snapshot from an instance of a virtual machine scale set:
$rgname = "myResourceGroup" $vmssname = "myVMScaleSet" $Id = 0 $location = "East US"
$vmss1 = Get-AzVmssVM -ResourceGroupName $rgname -VMScaleSetName $vmssname -InstanceId $Id
$snapshotconfig = New-AzSnapshotConfig -Location $location -AccountType Standard_LRS -OsType Windows -CreateOption Copy -SourceUri $vmss1.StorageProfile.OsDisk.ManagedDisk.id
New-AzSnapshot -ResourceGroupName $rgname -SnapshotName 'mySnapshot' -Snapshot $snapshotconfig
Create a managed disk from the snapshot:
$snapshotName = "myShapshot"
$snapshot = Get-AzSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotName
$diskConfig = New-AzDiskConfig -AccountType Premium_LRS -Location $location -CreateOption Copy -SourceResourceId $snapshot.Id
$osDisk = New-AzDisk -Disk $diskConfig -ResourceGroupName $rgname -DiskName ($snapshotName + '_Disk')
Upvotes: 1