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."); } }
/// <summary> /// The Stop Diagnostics operation begins an asynchronous operation to /// stopa 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 Stop Diagnostics operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<GatewayOperationResponse> StopDiagnosticsAsync(this IGatewayOperations operations, string networkName, StopGatewayPublicDiagnosticsParameters parameters) { return operations.StopDiagnosticsAsync(networkName, parameters, CancellationToken.None); }
/// <summary> /// The Stop Diagnostics operation begins an asynchronous operation to /// stopa 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 Stop Diagnostics operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static GatewayOperationResponse StopDiagnostics(this IGatewayOperations operations, string networkName, StopGatewayPublicDiagnosticsParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IGatewayOperations)s).StopDiagnosticsAsync(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 GatewayOperationResponse StopDiagnosticsV2(string gatewayId, StopGatewayPublicDiagnosticsParameters parameters) { return gatewayClient.StopDiagnosticsV2(gatewayId, parameters); }
public GatewayOperationResponse StopDiagnostics(string virtualNetworkSiteName, StopGatewayPublicDiagnosticsParameters parameters) { return gatewayClient.StopDiagnostics(virtualNetworkSiteName, parameters); }