/// <summary> /// Create a availability set /// </summary> /// <param name="locationName">Name of the location</param> /// <param name="numberOfFaultDomains">Number of fault domains</param> /// <param name="numberOfUpdateDomains">Number of update domains</param> /// <param name="allVirtualMachinesMustHaveManagedDisks">If set, creates an Aligned availability set, otherwise creates a classic availability set. Will also /// restrict the type of VMs added later</param> /// <param name="proximityGroup">Resource Uri of the Proximity Placement Group to assign the availability set to</param> /// <param name="tags">Tags to attach to the VM</param> public AvailabilitySet(string locationName, int numberOfFaultDomains, int numberOfUpdateDomains, bool allVirtualMachinesMustHaveManagedDisks = true, ResourceUri?proximityGroup = null, Dictionary <string, string>?tags = null) { if (string.IsNullOrWhiteSpace(locationName)) { throw new ArgumentNullException(nameof(locationName)); } if (numberOfFaultDomains <= 0) { throw new ArgumentOutOfRangeException(nameof(numberOfFaultDomains)); } if (numberOfUpdateDomains <= 0) { throw new ArgumentOutOfRangeException(nameof(numberOfUpdateDomains)); } Location = locationName; Sku = new ResourceSku() { Name = (allVirtualMachinesMustHaveManagedDisks ? "Aligned" : "Classic") }; Tags = tags; Properties = new AvailabilitySetProperties(numberOfFaultDomains, numberOfUpdateDomains, proximityGroup); }
/// <summary> /// Add a virtual machine to the availability set /// </summary> /// <param name="virtualMachine">ResourceUri of the VM to add</param> public void AddVirtualMachine(ResourceUri virtualMachine) { if (Properties == null) { Properties = new AvailabilitySetProperties(); } Properties.AddVirtualMachine(virtualMachine); }