/// <summary> /// Apply user input to the retrieved Availability Group Listener /// </summary> /// <param name="model">The Availability Group Listener that will be updated<param> /// <returns>The model to send to the update</returns> protected override IEnumerable <AzureAvailabilityGroupListenerModel> ApplyUserInputToModel(IEnumerable <AzureAvailabilityGroupListenerModel> model) { List <AzureAvailabilityGroupListenerModel> updateData = new List <AzureAvailabilityGroupListenerModel>(); AzureAvailabilityGroupListenerModel agListener = model.FirstOrDefault(); var loadBalancerConfiguration = agListener.LoadBalancerConfigurations.FirstOrDefault(); loadBalancerConfiguration.SqlVirtualMachineInstances = this.SqlVirtualMachineId; updateData.Add(agListener); return(updateData); }
/// <summary> /// Upserts a Availability Group Listener /// </summary> /// <param name="model">The Availability Group Listener to upsert</param> /// <returns>The updated Availability Group Listener model</returns> public AzureAvailabilityGroupListenerModel UpsertAvailabilityGroupListener(AzureAvailabilityGroupListenerModel model) { var resp = Communicator.CreateOrUpdate(model.ResourceGroupName, model.GroupName, model.Name, new AvailabilityGroupListener() { AvailabilityGroupName = model.AvailabilityGroupName, LoadBalancerConfigurations = model.LoadBalancerConfigurations, Port = model.Port }); return(CreateAvailabilityGroupListenerModelFromResponse(resp)); }
/// <summary> /// Convert a Management.SqlVirtualMachine.Models.AvailabilityGroupListenerModel to AzureAvailabilityGroupListenerModel /// </summary> /// <param name="resp">The management client sql virtual machine group response to convert</param> /// <returns>The converted sql virtual machine group model</returns> private static AzureAvailabilityGroupListenerModel CreateAvailabilityGroupListenerModelFromResponse(AvailabilityGroupListener resp) { // Extract the resource group name from the ID. string[] segments = resp.Id.Split('/'); AzureAvailabilityGroupListenerModel model = new AzureAvailabilityGroupListenerModel(segments[4], segments[8]) { Name = resp.Name, AvailabilityGroupName = resp.AvailabilityGroupName, Port = resp.Port, LoadBalancerConfigurations = resp.LoadBalancerConfigurations, ResourceId = resp.Id, ProvisioningState = resp.ProvisioningState }; return(model); }