By default it’s not necessary to have an Availability set for creating a new VM.  But Availability set is necessary if you are going to attach this VM to a load balancer.  We have to set the Availability set at the time of creation of VM.  At this moment it’s not possible to attach an existing VM to an Availability set.  For existing VMs you have create the VM again using the same configuration. That’s the only possible way at this moment.

I used below powershell commands to have an Availability set for my newly created VM.

For creating Availability set.

$AvSet = New-AzureRmAvailabilitySet -ResourceGroupName “VM” -Name “VMAvailabilitySet” -Location “East US”

During creation of VM, we input this Availability set with  “New-AzureRmVMConfig” cmdlet.
That’s how we attach VM to Availability set we have.

$myVm = New-AzureRmVMConfig -VMName "myVM2" -VMSize "Standard_D1_v2" -AvailabilitySetId $AvSet.Id

If we try to attach a VM doesn’t have any Availability set to an existing load balancer we will get error like below.

 “the new vm is not in the same availability group as the existing vm attached