/// <summary>
 /// Updates an internal load balancer associated with an existing
 /// deployment.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.ILoadBalancerOperations.
 /// </param>
 /// <param name='serviceName'>
 /// Required. The name of the service.
 /// </param>
 /// <param name='deploymentName'>
 /// Required. The name of the deployment.
 /// </param>
 /// <param name='loadBalancerName'>
 /// Required. The name of the loadBalancer.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Load Balancer operation.
 /// </param>
 /// <returns>
 /// The response body contains the status of the specified asynchronous
 /// operation, indicating whether it has succeeded, is inprogress, or
 /// has failed. Note that this status is distinct from the HTTP status
 /// code returned for the Get Operation Status operation itself. If
 /// the asynchronous operation succeeded, the response body includes
 /// the HTTP status code for the successful request. If the
 /// asynchronous operation failed, the response body includes the HTTP
 /// status code for the failed request and error information regarding
 /// the failure.
 /// </returns>
 public static Task<OperationStatusResponse> UpdateAsync(this ILoadBalancerOperations operations, string serviceName, string deploymentName, string loadBalancerName, LoadBalancerUpdateParameters parameters)
 {
     return operations.UpdateAsync(serviceName, deploymentName, loadBalancerName, parameters, CancellationToken.None);
 }
        protected PSArgument[] CreateLoadBalancerUpdateParameters()
        {
            string serviceName = string.Empty;
            string deploymentName = string.Empty;
            string loadBalancerName = string.Empty;
            LoadBalancerUpdateParameters parameters = new LoadBalancerUpdateParameters();

            return ConvertFromObjectsToArguments(new string[] { "ServiceName", "DeploymentName", "LoadBalancerName", "Parameters" }, new object[] { serviceName, deploymentName, loadBalancerName, parameters });
        }
 /// <summary>
 /// Updates an internal load balancer associated with an existing
 /// deployment.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.ILoadBalancerOperations.
 /// </param>
 /// <param name='serviceName'>
 /// Required. The name of the service.
 /// </param>
 /// <param name='deploymentName'>
 /// Required. The name of the deployment.
 /// </param>
 /// <param name='loadBalancerName'>
 /// Required. The name of the loadBalancer.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Load Balancer operation.
 /// </param>
 /// <returns>
 /// The response body contains the status of the specified asynchronous
 /// operation, indicating whether it has succeeded, is inprogress, or
 /// has failed. Note that this status is distinct from the HTTP status
 /// code returned for the Get Operation Status operation itself. If
 /// the asynchronous operation succeeded, the response body includes
 /// the HTTP status code for the successful request. If the
 /// asynchronous operation failed, the response body includes the HTTP
 /// status code for the failed request and error information regarding
 /// the failure.
 /// </returns>
 public static OperationStatusResponse Update(this ILoadBalancerOperations operations, string serviceName, string deploymentName, string loadBalancerName, LoadBalancerUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((ILoadBalancerOperations)s).UpdateAsync(serviceName, deploymentName, loadBalancerName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            var parameters = new LoadBalancerUpdateParameters()
            {
                Name = this.InternalLoadBalancerName,
                FrontendIPConfiguration = new FrontendIPConfiguration
                {
                    Type = FrontendIPConfigurationType.Private,
                    SubnetName = this.SubnetName,
                    StaticVirtualNetworkIPAddress = this.StaticVNetIPAddress == null ? null
                                                  : this.StaticVNetIPAddress.ToString()
                }
            };

            ExecuteClientActionNewSM(null,
                CommandRuntime.ToString(),
                () =>
                {
                    var deploymentName = this.ComputeClient.Deployments.GetBySlot(
                        this.ServiceName,
                        DeploymentSlot.Production).Name;

                    return this.ComputeClient.LoadBalancers.Update(
                        this.ServiceName,
                        deploymentName,
                        this.InternalLoadBalancerName,
                        parameters);
                });
        }