public void GenerateVpnClientPackageWithStaticRoutingConfiguration() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.EnsureSiteToSiteNetworkConfigurationExists(); networkTestClient.Gateways.EnsureNoGatewayExists(); const string networkName = "virtualNetworkSiteName"; GatewayGenerateVpnClientPackageParameters parameters = new GatewayGenerateVpnClientPackageParameters() { ProcessorArchitecture = GatewayProcessorArchitecture.Amd64, }; try { networkTestClient.Gateways.GenerateVpnClientPackage(networkName, parameters); Assert.True(false, "GenerateVpnClientPackage should have thrown a CloudException when the networkName was empty."); } catch (Hyak.Common.CloudException e) { Assert.Equal("BadRequest", e.Error.Code); Assert.Contains("current provisioning status of the gateway prevents this operation", e.Error.Message, StringComparison.InvariantCultureIgnoreCase); } } }
public void GenerateVpnClientPackageWithNotFoundNetworkName() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { const string networkName = "NotFoundNetworkName"; GatewayGenerateVpnClientPackageParameters parameters = new GatewayGenerateVpnClientPackageParameters() { ProcessorArchitecture = GatewayProcessorArchitecture.X86, }; try { networkTestClient.Gateways.GenerateVpnClientPackage(networkName, parameters); Assert.True(false, "GenerateVpnClientPackage should have thrown a CloudException when the networkName was empty."); } catch (Hyak.Common.CloudException e) { Assert.Equal("BadRequest", e.Error.Code); Assert.Contains(networkName, e.Error.Message); Assert.Contains("not valid or could not be found", e.Error.Message, StringComparison.InvariantCultureIgnoreCase); } } }
/// <summary> /// The Generate VPN Client Package operation creates a VPN client /// package for the specified virtual network and gateway in Azure. /// (see /// http://msdn.microsoft.com/en-us/library/windowsazure/dn205126.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='networkName'> /// Required. The name of the virtual network for this gateway. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Generate VPN Client Package /// operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<GatewayOperationResponse> BeginGenerateVpnClientPackageAsync(this IGatewayOperations operations, string networkName, GatewayGenerateVpnClientPackageParameters parameters) { return operations.BeginGenerateVpnClientPackageAsync(networkName, parameters, CancellationToken.None); }
/// <summary> /// The Generate VPN Client Package operation creates a VPN client /// package for the specified virtual network and gateway in Azure. /// (see /// http://msdn.microsoft.com/en-us/library/windowsazure/dn205126.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='networkName'> /// Required. The name of the virtual network for this gateway. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Generate VPN Client Package /// operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static GatewayOperationResponse BeginGenerateVpnClientPackage(this IGatewayOperations operations, string networkName, GatewayGenerateVpnClientPackageParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IGatewayOperations)s).BeginGenerateVpnClientPackageAsync(networkName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
public GatewayGetOperationStatusResponse GenerateVpnClientPackage(string virtualNetworkSiteName, GatewayGenerateVpnClientPackageParameters parameters) { return gatewayClient.GenerateVpnClientPackage(virtualNetworkSiteName, parameters); }
public void GenerateVpnClientPackageWithStaticRoutingGatewayWithNoClientRootCertificates() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.Gateways.EnsureStaticRoutingGatewayExists(); GatewayGenerateVpnClientPackageParameters parameters = new GatewayGenerateVpnClientPackageParameters() { ProcessorArchitecture = GatewayProcessorArchitecture.Amd64, }; try { networkTestClient.Gateways.GenerateVpnClientPackage(NetworkTestConstants.VirtualNetworkSiteName, parameters); Assert.True(false, "GenerateVpnClientPackage should throw a CloudException when there are no client root certificates uploaded for this virtual network."); } catch (Hyak.Common.CloudException e) { Assert.Equal("ResourceNotFound", e.Error.Code); Assert.Equal("There must be at least one client root certificate authority installed on the Gateway", e.Error.Message); Assert.NotNull(e.Response); Assert.Equal("Not Found", e.Response.ReasonPhrase); Assert.Equal(HttpStatusCode.NotFound, e.Response.StatusCode); } } }
/// <summary> /// The Generate VPN Client Package creates a VPN client package for /// the specified virtual network and gateway in Windows Azure. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/dn205126.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='virtualNetworkName'> /// The name of the virtual network for this gateway. /// </param> /// <param name='parameters'> /// Parameters supplied to the Create Virtual Network Gateway operation. /// </param> /// <returns> /// A standard storage response including an HTTP status code and /// request ID. /// </returns> public static GatewayOperationResponse GenerateVpnClientPackage(this IGatewayOperations operations, string virtualNetworkName, GatewayGenerateVpnClientPackageParameters parameters) { try { return operations.GenerateVpnClientPackageAsync(virtualNetworkName, parameters).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }