internal void ExecuteCommand()
        {
            ValidateParameters();
            StreamReader sr = null;
            try
            {
                sr = new StreamReader(this.ConfigurationPath);

                var netParams = new NetworkSetConfigurationParameters
                {
                    Configuration = sr.ReadToEnd()
                };

                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.NetworkClient.Networks.SetConfiguration(netParams));
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }
        }
 /// <summary>
 /// The Begin Setting Network Configuration operation asynchronously
 /// configures the virtual network.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157181.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Network.INetworkOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Set Network Configuration
 /// operation.
 /// </param>
 /// <returns>
 /// A standard storage response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static OperationResponse BeginSettingConfiguration(this INetworkOperations operations, NetworkSetConfigurationParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((INetworkOperations)s).BeginSettingConfigurationAsync(parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 public void SetConfigurationThrowsArgumentNullExceptionWhenConfigurationIsNull()
 {
     using (NetworkTestClient networkTestClient = new NetworkTestClient())
     {
         NetworkSetConfigurationParameters parameters = new NetworkSetConfigurationParameters();
         try
         {
             networkTestClient.SetNetworkConfiguration(parameters);
         }
         catch (ArgumentNullException e)
         {
             Assert.Equal("parameters.Configuration", e.ParamName);
         }
     }
 }
 /// <summary>
 /// The Set Network Configuration operation asynchronously configures
 /// the virtual network  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157181.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Network.INetworkOperations.
 /// </param>
 /// <param name='parameters'>
 /// The updated network configuration.
 /// </param>
 /// <returns>
 /// A standard storage response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static OperationResponse BeginSettingConfiguration(this INetworkOperations operations, NetworkSetConfigurationParameters parameters)
 {
     try
     {
         return operations.BeginSettingConfigurationAsync(parameters).Result;
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
        public void SetConfigurationWhenConfigurationIsEmpty()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                NetworkSetConfigurationParameters parameters = new NetworkSetConfigurationParameters()
                {
                    Configuration = string.Empty,
                };

                try
                {
                    networkTestClient.SetNetworkConfiguration(parameters);
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                }
            }
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            var netConfig = new XElement(
                NetconfigNamespace + "NetworkConfiguration",
                new XAttribute("xmlns", NetconfigNamespace.NamespaceName),
                new XAttribute(XNamespace.Xmlns + "xsi", InstanceNamespace.NamespaceName),
                new XElement(NetconfigNamespace + "VirtualNetworkConfiguration"));

            NetworkSetConfigurationParameters networkConfigParams = new NetworkSetConfigurationParameters
            {
                Configuration = netConfig.ToString()
            };

            ExecuteClientActionNewSM(
                null,
                CommandRuntime.ToString(),
                () => this.NetworkClient.Networks.SetConfiguration(networkConfigParams));
        }
        public OperationStatusResponse SetNetworkConfiguration(NetworkSetConfigurationParameters parameters)
        {
            SetNetworkConfiguration testOperation = new SetNetworkConfiguration(networkClient, parameters);

            InvokeTestOperation(testOperation);

            return testOperation.InvokeResponse;
        }
 /// <summary>
 /// The Set Network Configuration operation asynchronously configures
 /// the virtual network.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157181.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Network.INetworkOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Set Network Configuration
 /// 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 also includes error
 /// information regarding the failure.
 /// </returns>
 public static Task<OperationStatusResponse> SetConfigurationAsync(this INetworkOperations operations, NetworkSetConfigurationParameters parameters)
 {
     return operations.SetConfigurationAsync(parameters, CancellationToken.None);
 }
 /// <summary>
 /// The Begin Setting Network Configuration operation asynchronously
 /// configures the virtual network.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157181.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Network.INetworkOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Set Network Configuration
 /// operation.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task<AzureOperationResponse> BeginSettingConfigurationAsync(this INetworkOperations operations, NetworkSetConfigurationParameters parameters)
 {
     return operations.BeginSettingConfigurationAsync(parameters, CancellationToken.None);
 }
 public SetNetworkConfiguration(NetworkManagementClient networkClient, NetworkSetConfigurationParameters parameters)
 {
     this.networkClient = networkClient;
     this.parameters = parameters;
     oldNetworkConfiguration = GetConfigurationSafe();
 }