Asked by:
a single Virtual machine in an availability set

Question
-
What is best way step by step to get this single windows vm out of a availability set please?
- Moved by SadiqhAhmed-MSFTMicrosoft employee Thursday, May 7, 2020 6:30 AM For better audience
Wednesday, May 6, 2020 7:52 PM
All replies
-
Hello Chicojrman123,
The VM can be placed in availability set only at the time of creating the VM. So you have to delete the VM and recreate the VM. If you are looking for changing the availability set of a VM, you can refer this document which explains deleting the original VM and then recreating it in a new availability set.
If you are looking to completely remove the VM from availability set, then you can create a new VM from the disks. Please refer this document for instructions.
Also, you can use the below script to export the original VM’s configuration and re-create it base on the same configuration without Availability set (this is a modified version of the same script that is referenced above). If there are any backup's scheduled to the VM, request to stop the backup while doing this.
Request you to test this on a test VM before performing on the actual VM.
## Only need to replace the highlighted part # Set variables $resourceGroup = "myrg" $vmName = "myvm" # Get the details of the VM to be moved to the Availability Set $originalVM = Get-AzureRmVM ` -ResourceGroupName $resourceGroup ` -Name $vmName # Remove the original VM Remove-AzureRmVM -ResourceGroupName $resourceGroup -Name $vmName # Remove Availability set information $originalVM.AvailabilitySetReference = $null # Create the basic configuration for the replacement VM $newVM = New-AzureRmVMConfig ` -VMName $originalVM.Name ` -VMSize $originalVM.HardwareProfile.VmSize ` Set-AzureRmVMOSDisk ` -VM $newVM -CreateOption Attach ` -ManagedDiskId $originalVM.StorageProfile.OsDisk.ManagedDisk.Id ` -Name $originalVM.StorageProfile.OsDisk.Name ` -Windows # Add Data Disks foreach ($disk in $originalVM.StorageProfile.DataDisks) { Add-AzureRmVMDataDisk -VM $newVM ` -Name $disk.Name ` -ManagedDiskId $disk.ManagedDisk.Id ` -Caching $disk.Caching ` -Lun $disk.Lun ` -DiskSizeInGB $disk.DiskSizeGB ` -CreateOption Attach } # Add NIC(s) and keep the same NIC as primary foreach ($nic in $originalVM.NetworkProfile.NetworkInterfaces) { if ($nic.Primary -eq "True") { Add-AzureRmVMNetworkInterface ` -VM $newVM ` -Id $nic.Id -Primary } else { Add-AzureRmVMNetworkInterface ` -VM $newVM ` -Id $nic.Id } } # Recreate the VM New-AzureRmVM ` -ResourceGroupName $resourceGroup ` -Location $originalVM.Location ` -VM $newVM ` -DisableBginfoExtension
Thanks.
------------------------------------------------------------------------------------------------------------------
If the suggested response helped you resolve your issue, do click on "Mark as Answer" and "Up-Vote" for the answer that helped you for benefit of the community.
- Edited by VikasPullagura-MSFTMicrosoft employee Friday, May 8, 2020 7:07 AM
- Proposed as answer by VikasPullagura-MSFTMicrosoft employee Friday, May 8, 2020 7:07 AM
Friday, May 8, 2020 7:07 AM -
Hello,
Any update on the issue?
If the suggested response helped you resolve your issue, do click on "Mark as Answer" and "Up-Vote" for the answer that helped you for benefit of the community.
Thanks.Tuesday, May 12, 2020 3:01 PM -
Hello,
Any update on the issue?
If the suggested response helped you resolve your issue, do click on "Mark as Answer" and "Up-Vote" for the answer that helped you for benefit of the community.
Thanks.Tuesday, May 19, 2020 3:25 PM