public void StartDiagnosticsWithNotFoundVirtualNetworkName() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { StartGatewayPublicDiagnosticsParameters parameters = new StartGatewayPublicDiagnosticsParameters() { Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics, CustomerStorageName = "daschult20140611a", CustomerStorageKey = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==", ContainerName = "hydra-test-diagnostics", CaptureDurationInSeconds = "1", }; const string virtualNetworkName = "NotFoundVirtualNetworkName"; try { networkTestClient.Gateways.StartDiagnostics(virtualNetworkName, parameters); Assert.True(false, "UpdateDiagnostics should have thrown a CloudException when a virtual network name was provided that didn't exist."); } catch (Hyak.Common.CloudException e) { Assert.Equal("BadRequest", e.Error.Code); Assert.Contains(virtualNetworkName, e.Error.Message); Assert.Contains("not valid or could not be found", e.Error.Message); } } }
public void StartDiagnostics() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.Gateways.EnsureStaticRoutingGatewayExists(); StartGatewayPublicDiagnosticsParameters startParameters = new StartGatewayPublicDiagnosticsParameters() { Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics, CustomerStorageName = "daschult20140611a", // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")] CustomerStorageKey = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==", ContainerName = "hydra-test-diagnostics", CaptureDurationInSeconds = "300", }; GatewayGetOperationStatusResponse startResponse = networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, startParameters); Assert.NotNull(startResponse); Assert.Equal(HttpStatusCode.OK, startResponse.HttpStatusCode); GatewayDiagnosticsStatus startStatus = networkTestClient.Gateways.GetDiagnostics(NetworkTestConstants.VirtualNetworkSiteName); Assert.NotNull(startStatus); Assert.True(startStatus.DiagnosticsUrl != null, "The diagnostics url was null."); Assert.Equal(GatewayDiagnosticsState.InProgress, startStatus.State); StopGatewayPublicDiagnosticsParameters stopParameters = new StopGatewayPublicDiagnosticsParameters(); try { networkTestClient.Gateways.StopDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, stopParameters); Assert.True(false, "StopDiagnostics should throw a CloudException because the REST API is expecting a 202 (Accepted) status code, but GatewayManager is returning a 200 (OK)."); } catch (Hyak.Common.CloudException e) { Assert.Null(e.Error.Code); Assert.Null(e.Error.Message); Assert.NotNull(e.Response); Assert.Equal(HttpStatusCode.OK, e.Response.StatusCode); Assert.Equal("OK", e.Response.ReasonPhrase); } GatewayDiagnosticsStatus stopStatus; do { stopStatus = networkTestClient.Gateways.GetDiagnostics(NetworkTestConstants.VirtualNetworkSiteName); Assert.NotNull(stopStatus); } while (stopStatus.State != GatewayDiagnosticsState.Ready); Assert.Equal(GatewayDiagnosticsState.Ready, stopStatus.State); Assert.True(stopStatus.DiagnosticsUrl != null, "The diagnostics url was null."); Assert.True(1 <= stopStatus.DiagnosticsUrl.Length, "The diagnostics url was empty."); } }
public void StartDiagnosticsWithEmptyParameters() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.EnsureSiteToSiteNetworkConfigurationExists(); StartGatewayPublicDiagnosticsParameters parameters = new StartGatewayPublicDiagnosticsParameters(); try { networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, parameters); Assert.True(false, "UpdateDiagnostics should have thrown a CloudException with an InternalError."); } catch (Hyak.Common.CloudException e) { Assert.Equal("BadRequest", e.Error.Code); Assert.True(e.Error.Message.Contains("CustomerStorageName was not valid.")); } } }
/// <summary> /// The Begin Start Diagnostics operation begins an asynchronous /// operation to starta diagnostics session for the specified virtual /// network gateway in Azure. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/jj154119.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 Begin Start Diagnostics /// operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<GatewayOperationResponse> BeginStartDiagnosticsAsync(this IGatewayOperations operations, string networkName, StartGatewayPublicDiagnosticsParameters parameters) { return operations.BeginStartDiagnosticsAsync(networkName, parameters, CancellationToken.None); }
/// <summary> /// The Begin Start Diagnostics operation begins an asynchronous /// operation to starta diagnostics session for the specified virtual /// network gateway in Azure. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/jj154119.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 Begin Start Diagnostics /// operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static GatewayOperationResponse BeginStartDiagnostics(this IGatewayOperations operations, string networkName, StartGatewayPublicDiagnosticsParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IGatewayOperations)s).BeginStartDiagnosticsAsync(networkName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
public void DiagnosticsV2APIsTests() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { // 1.StartDiagnosticsV2 API // a.CreateVirtualnetworkGateway API string virtualNetworkSiteName = "coexistenceVirtualNetworkSiteName"; string vnetGatewayName = "coexistenceVnetGateway"; networkTestClient.EnsureNoNetworkConfigurationExists(virtualNetworkSiteName); networkTestClient.SetNetworkConfiguration(NetworkTestConstants.CoexistenceFeatureNetworkConfigurationParameters); NetworkListResponse listResponse = networkTestClient.ListNetworkConfigurations(); Assert.NotNull(listResponse); Assert.True(listResponse.VirtualNetworkSites.Any(vnet => vnet.Name.Equals(virtualNetworkSiteName)), "Virtual network:" + virtualNetworkSiteName + " is not found!"); string vnetId = listResponse.First(vnet => vnet.Name.Equals(virtualNetworkSiteName)).Id; GatewayGetOperationStatusResponse response = networkTestClient.Gateways.CreateVirtualNetworkGateway( virtualNetworkSiteName, new VirtualNetworkGatewayCreateParameters() { GatewayName = vnetGatewayName, GatewayType = GatewayType.DynamicRouting }); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); // Listvirtualnetworkgateways API ListVirtualNetworkGatewaysResponse listVirtualNetworkGatewaysResponse = networkTestClient.Gateways.ListVirtualNetworkGateways(); Assert.True(listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.Count >= 1); Guid vnetGatewayId = listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.First(vnetGateway => vnetGateway.GatewayName.Equals(vnetGatewayName)).GatewayId; // b.StartDiagnosticsV2 API StartGatewayPublicDiagnosticsParameters startParameters = new StartGatewayPublicDiagnosticsParameters() { Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics, CustomerStorageName = "daschult20140611a", // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")] CustomerStorageKey = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==", ContainerName = "hydra-test-diagnostics", CaptureDurationInSeconds = "60", }; GatewayGetOperationStatusResponse startResponse = networkTestClient.Gateways.StartDiagnosticsV2(vnetGatewayId.ToString(), startParameters); Assert.NotNull(startResponse); Assert.Equal(HttpStatusCode.OK, startResponse.HttpStatusCode); // 2.GetDiagnosticsV2 API GatewayDiagnosticsStatus startStatus = networkTestClient.Gateways.GetDiagnosticsV2(vnetGatewayId.ToString()); Assert.NotNull(startStatus); Assert.Equal(HttpStatusCode.OK, startStatus.StatusCode); Assert.True(startStatus.DiagnosticsUrl != null, "The diagnostics url was null."); Assert.Equal(GatewayDiagnosticsState.InProgress, startStatus.State); // StopDiagnosticsV2 API StopGatewayPublicDiagnosticsParameters stopParameters = new StopGatewayPublicDiagnosticsParameters(); GatewayOperationResponse gatewayOperationResponse = networkTestClient.Gateways.StopDiagnosticsV2(vnetGatewayId.ToString(), stopParameters); Assert.NotNull(gatewayOperationResponse); Assert.Equal(HttpStatusCode.Accepted, gatewayOperationResponse.StatusCode); GatewayDiagnosticsStatus stopStatus; do { stopStatus = networkTestClient.Gateways.GetDiagnosticsV2(vnetGatewayId.ToString()); Assert.NotNull(stopStatus); } while (stopStatus.State != GatewayDiagnosticsState.Ready); Assert.Equal(GatewayDiagnosticsState.Ready, stopStatus.State); Assert.True(stopStatus.DiagnosticsUrl != null, "The diagnostics url was null."); Assert.True(1 <= stopStatus.DiagnosticsUrl.Length, "The diagnostics url was empty."); // Cleanup test setup at end response = networkTestClient.Gateways.DeleteVirtualNetworkGateway(vnetGatewayId.ToString()); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); } }
public GatewayGetOperationStatusResponse StartDiagnosticsV2(string gatewayId, StartGatewayPublicDiagnosticsParameters parameters) { return gatewayClient.StartDiagnosticsV2(gatewayId, parameters); }
public GatewayGetOperationStatusResponse StartDiagnostics(string virtualNetworkSiteName, StartGatewayPublicDiagnosticsParameters parameters) { return gatewayClient.StartDiagnostics(virtualNetworkSiteName, parameters); }
public void StartDiagnosticsWithNoCustomerStorageName() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.EnsureSiteToSiteNetworkConfigurationExists(); StartGatewayPublicDiagnosticsParameters parameters = new StartGatewayPublicDiagnosticsParameters() { Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics, // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")] CustomerStorageKey = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==", ContainerName = "hydra-test-diagnostics", CaptureDurationInSeconds = "1", }; try { networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, parameters); Assert.True(false, "UpdateDiagnostics should have thrown a CloudException."); } catch (Hyak.Common.CloudException e) { Assert.Equal("BadRequest", e.Error.Code); Assert.True(e.Error.Message.Contains("CustomerStorageName was not valid")); } } }
public void StartDiagnosticsWithNoCustomerStorageKey() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.EnsureSiteToSiteNetworkConfigurationExists(); StartGatewayPublicDiagnosticsParameters parameters = new StartGatewayPublicDiagnosticsParameters() { Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics, CustomerStorageName = "daschult20140611a", ContainerName = "hydra-test-diagnostics", CaptureDurationInSeconds = "1", }; try { networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, parameters); Assert.True(false, "UpdateDiagnostics should have thrown a CloudException."); } catch (Hyak.Common.CloudException e) { Assert.Equal("BadRequest", e.Error.Code); Assert.True(e.Error.Message.Contains("CustomerStorageKey was not valid")); } } }
public void StartDiagnosticsWithNoContainerName() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.Gateways.EnsureStaticRoutingGatewayExists(); StartGatewayPublicDiagnosticsParameters startParameters = new StartGatewayPublicDiagnosticsParameters() { Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics, CustomerStorageName = "daschult20140611a", // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")] CustomerStorageKey = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==", CaptureDurationInSeconds = "1", }; GatewayGetOperationStatusResponse startResponse = networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, startParameters); Assert.NotNull(startResponse); Assert.Equal(HttpStatusCode.OK, startResponse.HttpStatusCode); GatewayDiagnosticsStatus stopStatus; do { stopStatus = networkTestClient.Gateways.GetDiagnostics(NetworkTestConstants.VirtualNetworkSiteName); Assert.NotNull(stopStatus); } while (stopStatus.State != GatewayDiagnosticsState.Ready); Assert.Equal(GatewayDiagnosticsState.Ready, stopStatus.State); Assert.True(stopStatus.DiagnosticsUrl != null, "The diagnostics url was null."); Assert.True(1 <= stopStatus.DiagnosticsUrl.Length, "The diagnostics url was empty."); } }
/// <summary> /// The Start Diagnostics V2 operation starts a diagnostics session for /// the specified virtual network gateway. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='gatewayId'> /// Required. The virtual network for this gateway Id. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Start Diagnostics V2 operation. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is in progress, 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<GatewayGetOperationStatusResponse> StartDiagnosticsV2Async(this IGatewayOperations operations, string gatewayId, StartGatewayPublicDiagnosticsParameters parameters) { return operations.StartDiagnosticsV2Async(gatewayId, parameters, CancellationToken.None); }
/// <summary> /// The Start Diagnostics V2 operation starts a diagnostics session for /// the specified virtual network gateway. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='gatewayId'> /// Required. The virtual network for this gateway Id. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Start Diagnostics V2 operation. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is in progress, 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 GatewayGetOperationStatusResponse StartDiagnosticsV2(this IGatewayOperations operations, string gatewayId, StartGatewayPublicDiagnosticsParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IGatewayOperations)s).StartDiagnosticsV2Async(gatewayId, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }