/// <summary> /// The Get Dedicated Circuit Peering Routing Information operation /// retrieves the ARP information for specific BGP. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IDedicatedCircuitPeeringRoutingInfoOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public or microsoft. /// </param> /// <param name='devicePath'> /// Required. Whether the device is primary or secondary. /// </param> /// <returns> /// The Get Dedicated Circuit Peering Route Table Info operation /// response. /// </returns> public static DedicatedCircuitPeeringRoutingInfoGetResponse Get(this IDedicatedCircuitPeeringRoutingInfoOperations operations, string serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath) { return Task.Factory.StartNew((object s) => { return ((IDedicatedCircuitPeeringRoutingInfoOperations)s).GetAsync(serviceKey, accessType, devicePath); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// The New Dedicated Circuit operation creates a new dedicated circuit. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the relationship between /// Azure and the customer. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the New Bgp Peering operation. /// </param> /// <returns> /// A standard express route gateway response including an HTTP status /// code and request ID. /// </returns> public static ExpressRouteOperationResponse BeginNew(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringNewParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IBgpPeeringOperations)s).BeginNewAsync(serviceKey, accessType, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
private AzureDedicatedCircuitStats compute(AzureDedicatedCircuitStats stats, Guid key, BgpPeeringAccessType type) { var tempstats = ExpressRouteClient.GetAzureDedicatedCircuitStatsInfo(key,type); stats.PrimaryBytesIn += tempstats.PrimaryBytesIn; stats.PrimaryBytesOut += tempstats.PrimaryBytesOut; stats.SecondaryBytesIn += tempstats.SecondaryBytesIn; stats.SecondaryBytesOut += tempstats.SecondaryBytesOut; return stats; }
public AzureBgpPeering NewAzureBGPPeering(string serviceKey, UInt32 peerAsn, string primaryPeerSubnet, string secondaryPeerSubnet, UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null) { return Client.BorderGatewayProtocolPeerings.New(serviceKey, accessType, new BorderGatewayProtocolPeeringNewParameters() { PeerAsn = peerAsn, PrimaryPeerSubnet = primaryPeerSubnet, SecondaryPeerSubnet = secondaryPeerSubnet, SharedKey = sharedKey, VlanId = vlanId }).BgpPeering; }
public AzureBgpPeering UpdateAzureBGPPeering(string serviceKey, BgpPeeringAccessType accessType, UInt32 peerAsn, string primaryPeerSubnet, string secondaryPeerSubnet, UInt32 vlanId, string sharedKey) { return (Client.BorderGatewayProtocolPeerings.Update(serviceKey, accessType, new BorderGatewayProtocolPeeringUpdateParameters() { PeerAsn = peerAsn, PrimaryPeerSubnet = primaryPeerSubnet, SecondaryPeerSubnet = secondaryPeerSubnet, SharedKey = sharedKey, VlanId = vlanId, })).BgpPeering; }
/// <summary> /// The New Dedicated Circuit operation creates a new dedicated circuit. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The service key representing the relationship between Azure and the /// customer. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Parameters supplied to the New Bgp Peering operation. /// </param> /// <returns> /// A standard express route gateway response including an HTTP status /// code and request ID. /// </returns> public static ExpressRouteOperationResponse BeginNew(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringNewParameters parameters) { try { return operations.BeginNewAsync(serviceKey, accessType, parameters).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
private AzureDedicatedCircuitStats compute(AzureDedicatedCircuitStats stats, Guid key, BgpPeeringAccessType type) { try { AzureBgpPeering peering = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, type); if (peering != null) { var tempstats = ExpressRouteClient.GetAzureDedicatedCircuitStatsInfo(key, type); stats.PrimaryBytesIn += tempstats.PrimaryBytesIn; stats.PrimaryBytesOut += tempstats.PrimaryBytesOut; stats.SecondaryBytesIn += tempstats.SecondaryBytesIn; stats.SecondaryBytesOut += tempstats.SecondaryBytesOut; } return stats; } catch { // The cirucit might not have corresponding peering return stats; } }
public string GetAzureDedicatedCircuitPeeringRouteTableSummary(Guid serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath) { return(Client.DedicatedCircuitPeeringRouteTableSummary.Get(serviceKey.ToString(), accessType, devicePath).Data.ToString()); }
public AzureDedicatedCircuitStats GetAzureDedicatedCircuitStatsInfo(Guid serviceKey, BgpPeeringAccessType accessType) { return(Client.DedicatedCircuitStats.Get(serviceKey.ToString(), accessType).DedicatedCircuitStats); }
/// <summary> /// The Get Dedicated Circuit Stats operation retrieves the /// bytesin/bytesout of the dedicated circuit on primary/secondary /// devices for specified peering type. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IDedicatedCircuitStatsOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public or microsoft. /// </param> /// <returns> /// The Get DedicatedCircuitStats operation response. /// </returns> public static Task<DedicatedCircuitStatsGetResponse> GetAsync(this IDedicatedCircuitStatsOperations operations, string serviceKey, BgpPeeringAccessType accessType) { return operations.GetAsync(serviceKey, accessType, CancellationToken.None); }
public AzureBgpPeering GetAzureBGPPeering(Guid serviceKey, BgpPeeringAccessType accessType) { return(Client.BorderGatewayProtocolPeerings.Get(serviceKey.ToString(), accessType).BgpPeering); }
/// <summary> /// The New Dedicated Circuit operation creates a new dedicated circuit. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the relationship between /// Azure and the customer. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the New Bgp Peering operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static ExpressRouteOperationResponse BeginNew(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BorderGatewayProtocolPeeringNewParameters parameters) { return(Task.Factory.StartNew((object s) => { return ((IBorderGatewayProtocolPeeringOperations)s).BeginNewAsync(serviceKey, accessType, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// The Update Bgp Peering operation updates an existing bgp peering or /// creates a new one if one doesn't exist. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The service key representing the relationship between Azure and the /// customer. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Parameters supplied to the Update Bgp Peering operation. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static Task<BgpPeeringGetResponse> UpdateAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringUpdateParameters parameters) { return operations.UpdateAsync(serviceKey, accessType, parameters, CancellationToken.None); }
/// <summary> /// The Get Bgp Peering operation retrieves the bgp peering for the /// dedicated circuit with the specified service key. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. The servicee key representing the dedicated circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static BgpPeeringGetResponse Get(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { return Task.Factory.StartNew((object s) => { return ((IBgpPeeringOperations)s).GetAsync(serviceKey, accessType); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// The New Border Gateway Protocol Peering operation creates a new /// Border Gateway Protocol Peering /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the relationship between /// Azure and the customer. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the New Border Gateway Protocol /// Peering operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task <ExpressRouteOperationResponse> BeginNewAsync(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BorderGatewayProtocolPeeringNewParameters parameters) { return(operations.BeginNewAsync(serviceKey, accessType, parameters, CancellationToken.None)); }
/// <summary> /// The Get DedicatedCircuitPeeringRouteTableSummary operation retrives /// RouteTableSummary. /// </summary> /// <param name='serviceKey'> /// Required. The service key representing the circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public or microsoft. /// </param> /// <param name='devicePath'> /// Required. Whether the device is primary or secondary. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public async Task <ExpressRouteOperationResponse> BeginGetAsync(string serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath, CancellationToken cancellationToken) { // Validate if (serviceKey == null) { throw new ArgumentNullException("serviceKey"); } // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("serviceKey", serviceKey); tracingParameters.Add("accessType", accessType); tracingParameters.Add("devicePath", devicePath); TracingAdapter.Enter(invocationId, this, "BeginGetAsync", tracingParameters); } // Construct URL string url = ""; url = url + "/"; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/services/networking/dedicatedcircuits/"; url = url + Uri.EscapeDataString(serviceKey); url = url + "/bgppeerings/"; url = url + Uri.EscapeDataString(ExpressRouteManagementClient.BgpPeeringAccessTypeToString(accessType)); url = url + "/routeTableSummary/"; url = url + Uri.EscapeDataString(ExpressRouteManagementClient.DevicePathToString(devicePath)); List <string> queryParameters = new List <string>(); queryParameters.Add("api-version=1.0"); if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters); } string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("x-ms-version", "2011-10-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { TracingAdapter.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { TracingAdapter.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.Accepted) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } // Create Result ExpressRouteOperationResponse result = null; // Deserialize Response if (statusCode == HttpStatusCode.Accepted) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new ExpressRouteOperationResponse(); XDocument responseDoc = XDocument.Parse(responseContent); XElement gatewayOperationAsyncResponseElement = responseDoc.Element(XName.Get("GatewayOperationAsyncResponse", "http://schemas.microsoft.com/windowsazure")); if (gatewayOperationAsyncResponseElement != null) { XElement idElement = gatewayOperationAsyncResponseElement.Element(XName.Get("ID", "http://schemas.microsoft.com/windowsazure")); if (idElement != null) { string idInstance = idElement.Value; result.OperationId = idInstance; } } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
/// <summary> /// The Get DedicatedCircuitPeeringRouteTableSummary operation retrives /// RouteTableSummary. /// </summary> /// <param name='serviceKey'> /// Required. The service key representing the circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public or microsoft. /// </param> /// <param name='devicePath'> /// Required. Whether the device is primary or secondary. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </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 async Task <ExpressRouteOperationStatusResponse> GetAsync(string serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath, CancellationToken cancellationToken) { ExpressRouteManagementClient client = this.Client; bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("serviceKey", serviceKey); tracingParameters.Add("accessType", accessType); tracingParameters.Add("devicePath", devicePath); TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); } cancellationToken.ThrowIfCancellationRequested(); ExpressRouteOperationResponse response = await client.DedicatedCircuitPeeringRouteTableSummary.BeginGetAsync(serviceKey, accessType, devicePath, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); ExpressRouteOperationStatusResponse result = await client.DedicatedCircuitPeeringArpInfo.GetOperationStatusAsync(response.OperationId, cancellationToken).ConfigureAwait(false); int delayInSeconds = 30; if (client.LongRunningOperationInitialTimeout >= 0) { delayInSeconds = client.LongRunningOperationInitialTimeout; } while (result.Status == ExpressRouteOperationStatus.InProgress) { cancellationToken.ThrowIfCancellationRequested(); await TaskEx.Delay(delayInSeconds * 1000, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); result = await client.DedicatedCircuitPeeringArpInfo.GetOperationStatusAsync(response.OperationId, cancellationToken).ConfigureAwait(false); delayInSeconds = 30; if (client.LongRunningOperationRetryTimeout >= 0) { delayInSeconds = client.LongRunningOperationRetryTimeout; } } if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } if (result.Status != ExpressRouteOperationStatus.Successful) { if (result.Error != null) { CloudException ex = new CloudException(result.Error.Code + " : " + result.Error.Message); ex.Error = new CloudError(); ex.Error.Code = result.Error.Code; ex.Error.Message = result.Error.Message; if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } else { CloudException ex = new CloudException(""); if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } } return(result); }
/// <summary> /// The Remove Bgp Peering operation deletes an existing bgp peering. /// </summary> /// <param name='serviceKey'> /// Required. Service key associated with the bgp peering to be deleted. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </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 async System.Threading.Tasks.Task <Microsoft.WindowsAzure.Management.ExpressRoute.Models.ExpressRouteOperationStatusResponse> RemoveAsync(string serviceKey, BgpPeeringAccessType accessType, CancellationToken cancellationToken) { ExpressRouteManagementClient client = this.Client; bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("serviceKey", serviceKey); tracingParameters.Add("accessType", accessType); Tracing.Enter(invocationId, this, "RemoveAsync", tracingParameters); } try { if (shouldTrace) { client = this.Client.WithHandler(new ClientRequestTrackingHandler(invocationId)); } cancellationToken.ThrowIfCancellationRequested(); ExpressRouteOperationResponse originalResponse = await client.BgpPeering.BeginRemoveAsync(serviceKey, accessType, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); ExpressRouteOperationStatusResponse result = await client.GetOperationStatusAsync(originalResponse.OperationId, cancellationToken).ConfigureAwait(false); int delayInSeconds = 30; while (result.Status == ExpressRouteOperationStatus.InProgress) { cancellationToken.ThrowIfCancellationRequested(); await TaskEx.Delay(delayInSeconds * 1000, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); result = await client.GetOperationStatusAsync(originalResponse.OperationId, cancellationToken).ConfigureAwait(false); delayInSeconds = 10; } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (client != null && shouldTrace) { client.Dispose(); } } }
/// <summary> /// The New Dedicated Circuit operation creates a new dedicated circuit. /// </summary> /// <param name='serviceKey'> /// Required. The service key representing the relationship between /// Azure and the customer. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the New Bgp Peering operation. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// A standard express route gateway response including an HTTP status /// code and request ID. /// </returns> public async System.Threading.Tasks.Task <Microsoft.WindowsAzure.Management.ExpressRoute.Models.ExpressRouteOperationResponse> BeginNewAsync(string serviceKey, BgpPeeringAccessType accessType, BgpPeeringNewParameters parameters, CancellationToken cancellationToken) { // Validate if (serviceKey == null) { throw new ArgumentNullException("serviceKey"); } if (serviceKey.Length > 36) { throw new ArgumentOutOfRangeException("serviceKey"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } if (parameters.PrimaryPeerSubnet == null) { throw new ArgumentNullException("parameters.PrimaryPeerSubnet"); } if (parameters.PrimaryPeerSubnet.Length > 18) { throw new ArgumentOutOfRangeException("parameters.PrimaryPeerSubnet"); } if (parameters.SecondaryPeerSubnet == null) { throw new ArgumentNullException("parameters.SecondaryPeerSubnet"); } if (parameters.SecondaryPeerSubnet.Length > 18) { throw new ArgumentOutOfRangeException("parameters.SecondaryPeerSubnet"); } if (parameters.SharedKey != null && parameters.SharedKey.Length < 6) { throw new ArgumentOutOfRangeException("parameters.SharedKey"); } if (parameters.SharedKey != null && parameters.SharedKey.Length > 24) { throw new ArgumentOutOfRangeException("parameters.SharedKey"); } // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("serviceKey", serviceKey); tracingParameters.Add("accessType", accessType); tracingParameters.Add("parameters", parameters); Tracing.Enter(invocationId, this, "BeginNewAsync", tracingParameters); } // Construct URL string baseUrl = this.Client.BaseUri.AbsoluteUri; string url = "/" + (this.Client.Credentials.SubscriptionId != null ? this.Client.Credentials.SubscriptionId.Trim() : "") + "/services/networking/dedicatedcircuits/" + serviceKey.Trim() + "/bgppeerings/" + accessType + "?api-version=1.0"; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Post; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("x-ms-version", "2011-10-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Serialize Request string requestContent = null; XDocument requestDoc = new XDocument(); XElement createBgpPeeringElement = new XElement(XName.Get("CreateBgpPeering", "http://schemas.microsoft.com/windowsazure")); requestDoc.Add(createBgpPeeringElement); XElement peerAsnElement = new XElement(XName.Get("PeerAsn", "http://schemas.microsoft.com/windowsazure")); peerAsnElement.Value = parameters.PeerAsn.ToString(); createBgpPeeringElement.Add(peerAsnElement); XElement primaryPeerSubnetElement = new XElement(XName.Get("PrimaryPeerSubnet", "http://schemas.microsoft.com/windowsazure")); primaryPeerSubnetElement.Value = parameters.PrimaryPeerSubnet; createBgpPeeringElement.Add(primaryPeerSubnetElement); XElement secondaryPeerSubnetElement = new XElement(XName.Get("SecondaryPeerSubnet", "http://schemas.microsoft.com/windowsazure")); secondaryPeerSubnetElement.Value = parameters.SecondaryPeerSubnet; createBgpPeeringElement.Add(secondaryPeerSubnetElement); if (parameters.SharedKey != null) { XElement sharedKeyElement = new XElement(XName.Get("SharedKey", "http://schemas.microsoft.com/windowsazure")); sharedKeyElement.Value = parameters.SharedKey; createBgpPeeringElement.Add(sharedKeyElement); } XElement vlanIdElement = new XElement(XName.Get("VlanId", "http://schemas.microsoft.com/windowsazure")); vlanIdElement.Value = parameters.VlanId.ToString(); createBgpPeeringElement.Add(vlanIdElement); requestContent = requestDoc.ToString(); httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); httpRequest.Content.Headers.ContentType = new MediaTypeHeaderValue("application/xml"); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.Accepted) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false), CloudExceptionType.Xml); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result ExpressRouteOperationResponse result = null; // Deserialize Response cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new ExpressRouteOperationResponse(); XDocument responseDoc = XDocument.Parse(responseContent); XElement gatewayOperationAsyncResponseElement = responseDoc.Element(XName.Get("GatewayOperationAsyncResponse", "http://schemas.microsoft.com/windowsazure")); if (gatewayOperationAsyncResponseElement != null) { XElement idElement = gatewayOperationAsyncResponseElement.Element(XName.Get("ID", "http://schemas.microsoft.com/windowsazure")); if (idElement != null) { string idInstance = idElement.Value; result.OperationId = idInstance; } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
/// <summary> /// The Get Bgp Peering operation retrieves the bgp peering for the /// dedicated circuit with the specified service key. /// </summary> /// <param name='serviceKey'> /// Required. The servicee key representing the dedicated circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public async System.Threading.Tasks.Task <Microsoft.WindowsAzure.Management.ExpressRoute.Models.BgpPeeringGetResponse> GetAsync(string serviceKey, BgpPeeringAccessType accessType, CancellationToken cancellationToken) { // Validate if (serviceKey == null) { throw new ArgumentNullException("serviceKey"); } // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("serviceKey", serviceKey); tracingParameters.Add("accessType", accessType); Tracing.Enter(invocationId, this, "GetAsync", tracingParameters); } // Construct URL string baseUrl = this.Client.BaseUri.AbsoluteUri; string url = "/" + (this.Client.Credentials.SubscriptionId != null ? this.Client.Credentials.SubscriptionId.Trim() : "") + "/services/networking/dedicatedcircuits/" + serviceKey.Trim() + "/bgppeerings/" + accessType + "?api-version=1.0"; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("x-ms-version", "2011-10-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false), CloudExceptionType.Xml); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result BgpPeeringGetResponse result = null; // Deserialize Response cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new BgpPeeringGetResponse(); XDocument responseDoc = XDocument.Parse(responseContent); XElement bgpPeeringElement = responseDoc.Element(XName.Get("BgpPeering", "http://schemas.microsoft.com/windowsazure")); if (bgpPeeringElement != null) { AzureBgpPeering bgpPeeringInstance = new AzureBgpPeering(); result.BgpPeering = bgpPeeringInstance; XElement azureAsnElement = bgpPeeringElement.Element(XName.Get("AzureAsn", "http://schemas.microsoft.com/windowsazure")); if (azureAsnElement != null) { uint azureAsnInstance = uint.Parse(azureAsnElement.Value, CultureInfo.InvariantCulture); bgpPeeringInstance.AzureAsn = azureAsnInstance; } XElement peerAsnElement = bgpPeeringElement.Element(XName.Get("PeerAsn", "http://schemas.microsoft.com/windowsazure")); if (peerAsnElement != null) { uint peerAsnInstance = uint.Parse(peerAsnElement.Value, CultureInfo.InvariantCulture); bgpPeeringInstance.PeerAsn = peerAsnInstance; } XElement primaryAzurePortElement = bgpPeeringElement.Element(XName.Get("PrimaryAzurePort", "http://schemas.microsoft.com/windowsazure")); if (primaryAzurePortElement != null) { string primaryAzurePortInstance = primaryAzurePortElement.Value; bgpPeeringInstance.PrimaryAzurePort = primaryAzurePortInstance; } XElement primaryPeerSubnetElement = bgpPeeringElement.Element(XName.Get("PrimaryPeerSubnet", "http://schemas.microsoft.com/windowsazure")); if (primaryPeerSubnetElement != null) { string primaryPeerSubnetInstance = primaryPeerSubnetElement.Value; bgpPeeringInstance.PrimaryPeerSubnet = primaryPeerSubnetInstance; } XElement secondaryAzurePortElement = bgpPeeringElement.Element(XName.Get("SecondaryAzurePort", "http://schemas.microsoft.com/windowsazure")); if (secondaryAzurePortElement != null) { string secondaryAzurePortInstance = secondaryAzurePortElement.Value; bgpPeeringInstance.SecondaryAzurePort = secondaryAzurePortInstance; } XElement secondaryPeerSubnetElement = bgpPeeringElement.Element(XName.Get("SecondaryPeerSubnet", "http://schemas.microsoft.com/windowsazure")); if (secondaryPeerSubnetElement != null) { string secondaryPeerSubnetInstance = secondaryPeerSubnetElement.Value; bgpPeeringInstance.SecondaryPeerSubnet = secondaryPeerSubnetInstance; } XElement stateElement = bgpPeeringElement.Element(XName.Get("State", "http://schemas.microsoft.com/windowsazure")); if (stateElement != null) { BGPPeeringState stateInstance = ((BGPPeeringState)Enum.Parse(typeof(BGPPeeringState), stateElement.Value, true)); bgpPeeringInstance.State = stateInstance; } XElement vlanIdElement = bgpPeeringElement.Element(XName.Get("VlanId", "http://schemas.microsoft.com/windowsazure")); if (vlanIdElement != null) { uint vlanIdInstance = uint.Parse(vlanIdElement.Value, CultureInfo.InvariantCulture); bgpPeeringInstance.VlanId = vlanIdInstance; } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
public bool RemoveAzureBGPPeering(string serviceKey, BgpPeeringAccessType accessType) { var result = Client.BgpPeering.Remove(serviceKey, accessType); return(result.HttpStatusCode.Equals(HttpStatusCode.OK)); }
/// <summary> /// The Update Border Gateway Protocol Peering operation updates an /// existing bgp peering. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the relationship between /// Azure and the customer. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Update Border Gateway Protocol /// Peering operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<ExpressRouteOperationResponse> BeginUpdateAsync(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BorderGatewayProtocolPeeringUpdateParameters parameters) { return operations.BeginUpdateAsync(serviceKey, accessType, parameters, CancellationToken.None); }
/// <summary> /// The Remove Border Gateway Protocol Peering operation deletes an /// existing border gateway protocol peering. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. Service key associated with the border gateway protocol /// peering to be deleted. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </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 ExpressRouteOperationStatusResponse Remove(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { return Task.Factory.StartNew((object s) => { return ((IBorderGatewayProtocolPeeringOperations)s).RemoveAsync(serviceKey, accessType); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// The Get DedicatedCircuitPeeringRouteTableSummary operation retrives /// RouteTableSummary. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IDedicatedCircuitPeeringRouteTableSummaryOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public or microsoft. /// </param> /// <param name='devicePath'> /// Required. Whether the device is primary or secondary. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static ExpressRouteOperationResponse BeginGet(this IDedicatedCircuitPeeringRouteTableSummaryOperations operations, string serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath) { return(Task.Factory.StartNew((object s) => { return ((IDedicatedCircuitPeeringRouteTableSummaryOperations)s).BeginGetAsync(serviceKey, accessType, devicePath); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
public AzureBgpPeering NewAzureBGPPeering(string serviceKey, UInt32 peerAsn, string primaryPeerSubnet, string secondaryPeerSubnet, UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null) { return(Client.BgpPeering.New(serviceKey, accessType, new BgpPeeringNewParameters() { PeerAsn = peerAsn, PrimaryPeerSubnet = primaryPeerSubnet, SecondaryPeerSubnet = secondaryPeerSubnet, SharedKey = sharedKey, VlanId = vlanId }).BgpPeering); }
/// <summary> /// The Get DedicatedCircuitPeeringRouteTableSummary operation retrives /// RouteTableSummary. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IDedicatedCircuitPeeringRouteTableSummaryOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public or microsoft. /// </param> /// <param name='devicePath'> /// Required. Whether the device is primary or secondary. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task <ExpressRouteOperationResponse> BeginGetAsync(this IDedicatedCircuitPeeringRouteTableSummaryOperations operations, string serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath) { return(operations.BeginGetAsync(serviceKey, accessType, devicePath, CancellationToken.None)); }
public bool RemoveAzureBGPPeering(Guid serviceKey, BgpPeeringAccessType accessType) { var result = Client.BorderGatewayProtocolPeerings.Remove(serviceKey.ToString(), accessType); return(result.HttpStatusCode.Equals(HttpStatusCode.OK)); }
/// <summary> /// The Remove Bgp Peering Route operation deletes an existing bgp /// peering. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// Service Key representing the bgp peering to be deleted. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <returns> /// A standard express route gateway response including an HTTP status /// code and request ID. /// </returns> public static Task <ExpressRouteOperationResponse> BeginRemoveAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { return(operations.BeginRemoveAsync(serviceKey, accessType, CancellationToken.None)); }
/// <summary> /// The Update Bgp Peering operation updates an existing bgp peering. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The service key representing the relationship between Azure and the /// customer. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Parameters supplied to the Update Bgp Peering operation. /// </param> /// <returns> /// A standard express route gateway response including an HTTP status /// code and request ID. /// </returns> public static Task <ExpressRouteOperationResponse> BeginUpdateAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringUpdateParameters parameters) { return(operations.BeginUpdateAsync(serviceKey, accessType, parameters, CancellationToken.None)); }
/// <summary> /// The Get Bgp Peering operation retrieves the bgp peering for the /// dedicated circuit with the specified service key. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The servicee key representing the dedicated circuit. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static BgpPeeringGetResponse Get(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { try { return(operations.GetAsync(serviceKey, accessType).Result); } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
public AzureBgpPeering GetAzureBGPPeering(string serviceKey, BgpPeeringAccessType accessType) { return Client.BgpPeering.Get(serviceKey, accessType).BgpPeering; }
/// <summary> /// The New Bgp Peering operation creates a new bgp peering associated /// with the dedicated circuit specified by the service key provided. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The service key representing the relationship between Azure and the /// customer. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Parameters supplied to the New Bgp Peering operation. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static Task <BgpPeeringGetResponse> NewAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringNewParameters parameters) { return(operations.NewAsync(serviceKey, accessType, parameters, CancellationToken.None)); }
public AzureBgpPeering GetAzureBGPPeering(string serviceKey, BgpPeeringAccessType accessType) { return Client.BorderGatewayProtocolPeerings.Get(serviceKey, accessType).BgpPeering; }
/// <summary> /// The Remove Bgp Peering operation deletes an existing bgp peering. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// Service key associated with the bgp peering to be deleted. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </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 ExpressRouteOperationStatusResponse Remove(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { try { return(operations.RemoveAsync(serviceKey, accessType).Result); } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
public bool RemoveAzureBGPPeering(string serviceKey, BgpPeeringAccessType accessType) { var result = Client.BorderGatewayProtocolPeerings.Remove(serviceKey, accessType); return result.HttpStatusCode.Equals(HttpStatusCode.OK); }
public AzureBgpPeering NewAzureBGPPeering(Guid serviceKey, string advertisedPublicPrefixes, UInt32 customerAsn, UInt32 peerAsn, string primaryPeerSubnet, string routingRegistryName, string secondaryPeerSubnet, UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null) { var result = Client.BorderGatewayProtocolPeerings.New(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringNewParameters() { AdvertisedPublicPrefixes = advertisedPublicPrefixes, CustomerAutonomousSystemNumber = customerAsn, PeerAutonomousSystemNumber = peerAsn, PrimaryPeerSubnet = primaryPeerSubnet, RoutingRegistryName = routingRegistryName, SecondaryPeerSubnet = secondaryPeerSubnet, SharedKey = sharedKey, VirtualLanId = vlanId }); if (result.HttpStatusCode.Equals(HttpStatusCode.OK)) { return(GetAzureBGPPeering(serviceKey, accessType)); } else { throw new Exception(result.Error.ToString()); } }
/// <summary> /// The Get DedicatedCircuitPeeringRouteTableSummary operation retrives /// RouteTableSummary. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IDedicatedCircuitPeeringRouteTableSummaryOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public or microsoft. /// </param> /// <param name='devicePath'> /// Required. Whether the device is primary or secondary. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<ExpressRouteOperationResponse> BeginGetAsync(this IDedicatedCircuitPeeringRouteTableSummaryOperations operations, string serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath) { return operations.BeginGetAsync(serviceKey, accessType, devicePath, CancellationToken.None); }
/// <summary> /// The New Dedicated Circuit operation creates a new dedicated circuit. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The service key representing the relationship between Azure and the /// customer. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Parameters supplied to the New Bgp Peering operation. /// </param> /// <returns> /// A standard express route gateway response including an HTTP status /// code and request ID. /// </returns> public static Task<ExpressRouteOperationResponse> BeginNewAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringNewParameters parameters) { return operations.BeginNewAsync(serviceKey, accessType, parameters, CancellationToken.None); }
/// <summary> /// The New Border Gateway Protocol Peering operation creates a new /// border gateway protocol peering associated with the dedicated /// circuit specified by the service key provided. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the relationship between /// Azure and the customer. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the New Bgp Peering operation. /// </param> /// <returns> /// The Get Border Gateway Protocol Peering Operation Response. /// </returns> public static Task<BorderGatewayProtocolPeeringGetResponse> NewAsync(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BorderGatewayProtocolPeeringNewParameters parameters) { return operations.NewAsync(serviceKey, accessType, parameters, CancellationToken.None); }
/// <summary> /// The Get Bgp Peering operation retrieves the bgp peering for the /// dedicated circuit with the specified service key. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The servicee key representing the dedicated circuit. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static Task<BgpPeeringGetResponse> GetAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { return operations.GetAsync(serviceKey, accessType, CancellationToken.None); }
/// <summary> /// The Update Border Gateway Protocol Peering operation updates an /// existing border gateway protocol peering or creates a new one if /// one doesn't exist. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the relationship between /// Azure and the customer. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Update Border Gateway Protocol /// Peering operation. /// </param> /// <returns> /// The Get Border Gateway Protocol Peering Operation Response. /// </returns> public static BorderGatewayProtocolPeeringGetResponse Update(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BorderGatewayProtocolPeeringUpdateParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IBorderGatewayProtocolPeeringOperations)s).UpdateAsync(serviceKey, accessType, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// The Remove Bgp Peering operation deletes an existing bgp peering. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// Service key associated with the bgp peering to be deleted. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </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<ExpressRouteOperationStatusResponse> RemoveAsync(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { return operations.RemoveAsync(serviceKey, accessType, CancellationToken.None); }
/// <summary> /// The Update Bgp Peering operation updates an existing bgp peering or /// creates a new one if one doesn't exist. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The service key representing the relationship between Azure and the /// customer. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Parameters supplied to the Update Bgp Peering operation. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static BgpPeeringGetResponse Update(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringUpdateParameters parameters) { try { return(operations.UpdateAsync(serviceKey, accessType, parameters).Result); } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
public AzureBgpPeering GetAzureBGPPeering(string serviceKey, BgpPeeringAccessType accessType) { return(Client.BgpPeering.Get(serviceKey, accessType).BgpPeering); }
/// <summary> /// The Get Dedicated Circuit Peering Routing Information operation /// retrieves the ARP information for specific BGP. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IDedicatedCircuitPeeringRoutingInfoOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public or microsoft. /// </param> /// <param name='devicePath'> /// Required. Whether the device is primary or secondary. /// </param> /// <returns> /// The Get Dedicated Circuit Peering Route Table Info operation /// response. /// </returns> public static Task<DedicatedCircuitPeeringRoutingInfoGetResponse> GetAsync(this IDedicatedCircuitPeeringRoutingInfoOperations operations, string serviceKey, BgpPeeringAccessType accessType, DevicePath devicePath) { return operations.GetAsync(serviceKey, accessType, devicePath, CancellationToken.None); }
/// <summary> /// The New Dedicated Circuit operation creates a new dedicated circuit. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The service key representing the relationship between Azure and the /// customer. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Parameters supplied to the New Bgp Peering operation. /// </param> /// <returns> /// A standard express route gateway response including an HTTP status /// code and request ID. /// </returns> public static ExpressRouteOperationResponse BeginNew(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringNewParameters parameters) { try { return(operations.BeginNewAsync(serviceKey, accessType, parameters).Result); } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
/// <summary> /// The Get Bgp Peering operation retrieves the bgp peering for the /// dedicated circuit with the specified service key. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The servicee key representing the dedicated circuit. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static BgpPeeringGetResponse Get(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { try { return operations.GetAsync(serviceKey, accessType).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
/// <summary> /// The Get Bgp Peering operation retrieves the bgp peering for the /// dedicated circuit with the specified service key. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. The servicee key representing the dedicated circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static BorderGatewayProtocolPeeringGetResponse Get(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { return(Task.Factory.StartNew((object s) => { return ((IBorderGatewayProtocolPeeringOperations)s).GetAsync(serviceKey, accessType); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// The Remove Bgp Peering operation deletes an existing bgp peering. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// Service key associated with the bgp peering to be deleted. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </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 ExpressRouteOperationStatusResponse Remove(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { try { return operations.RemoveAsync(serviceKey, accessType).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
/// <summary> /// The Get Bgp Peering operation retrieves the bgp peering for the /// dedicated circuit with the specified service key. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. The servicee key representing the dedicated circuit. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static Task <BorderGatewayProtocolPeeringGetResponse> GetAsync(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { return(operations.GetAsync(serviceKey, accessType, CancellationToken.None)); }
/// <summary> /// The Update Bgp Peering operation updates an existing bgp peering or /// creates a new one if one doesn't exist. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBgpPeeringOperations. /// </param> /// <param name='serviceKey'> /// The service key representing the relationship between Azure and the /// customer. /// </param> /// <param name='accessType'> /// Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Parameters supplied to the Update Bgp Peering operation. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static BgpPeeringGetResponse Update(this IBgpPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeeringUpdateParameters parameters) { try { return operations.UpdateAsync(serviceKey, accessType, parameters).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
/// <summary> /// The Remove Bgp Peering operation deletes an existing bgp peering. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. Service key associated with the bgp peering to be deleted. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </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 <ExpressRouteOperationStatusResponse> RemoveAsync(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType) { return(operations.RemoveAsync(serviceKey, accessType, CancellationToken.None)); }
/// <summary> /// The Update Bgp Peering operation updates an existing bgp peering or /// creates a new one if one doesn't exist. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. The service key representing the relationship between /// Azure and the customer. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Update Bgp Peering operation. /// </param> /// <returns> /// The Get Bgp Peering Operation Response. /// </returns> public static Task <BorderGatewayProtocolPeeringGetResponse> UpdateAsync(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BorderGatewayProtocolPeeringUpdateParameters parameters) { return(operations.UpdateAsync(serviceKey, accessType, parameters, CancellationToken.None)); }
public void SetBgpPeeringSuccessful() { // Setup string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; UInt32 peerAsn = 64496; string primaryPeerSubnet = "aaa"; string newPrimaryPeerSubnet = "ccc"; string secondayPeerSubnet = "bbb"; UInt32 azureAsn = 64494; string primaryAzurePort = "8081"; string secondaryAzurePort = "8082"; BGPPeeringState state = BGPPeeringState.Enabled; uint vlanId = 2; BgpPeeringAccessType accessType = BgpPeeringAccessType.Private; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var bgpMock = new Mock <IBgpPeeringOperations>(); BgpPeeringGetResponse expected = new BgpPeeringGetResponse() { BgpPeering = new AzureBgpPeering() { AzureAsn = azureAsn, PeerAsn = peerAsn, PrimaryAzurePort = primaryAzurePort, PrimaryPeerSubnet = primaryPeerSubnet, SecondaryAzurePort = secondaryAzurePort, SecondaryPeerSubnet = secondayPeerSubnet, State = state, VlanId = vlanId }, RequestId = "", StatusCode = new HttpStatusCode() }; var t = new Task <BgpPeeringGetResponse>(() => expected); t.Start(); BgpPeeringGetResponse expected2 = new BgpPeeringGetResponse() { BgpPeering = new AzureBgpPeering() { AzureAsn = azureAsn, PeerAsn = peerAsn, PrimaryAzurePort = primaryAzurePort, PrimaryPeerSubnet = newPrimaryPeerSubnet, SecondaryAzurePort = secondaryAzurePort, SecondaryPeerSubnet = secondayPeerSubnet, State = state, VlanId = vlanId }, RequestId = "", StatusCode = new HttpStatusCode() }; var t2 = new Task <BgpPeeringGetResponse>(() => expected2); t2.Start(); bgpMock.Setup( f => f.GetAsync(It.Is <string>(x => x == serviceKey), It.Is <BgpPeeringAccessType>( y => y == accessType), It.IsAny <CancellationToken>())) .Returns((string sKey, BgpPeeringAccessType atype, CancellationToken cancellation) => t); bgpMock.Setup( f => f.UpdateAsync(It.Is <string>(x => x == serviceKey), It.Is <BgpPeeringAccessType>( y => y == accessType), It.Is <BgpPeeringUpdateParameters>(z => z.PrimaryPeerSubnet == newPrimaryPeerSubnet), It.IsAny <CancellationToken>())) .Returns((string sKey, BgpPeeringAccessType atype, BgpPeeringUpdateParameters param, CancellationToken cancellation) => t2); client.SetupGet(f => f.BgpPeering).Returns(bgpMock.Object); SetAzureBGPPeeringCommand cmdlet = new SetAzureBGPPeeringCommand() { ServiceKey = serviceKey, AccessType = accessType, PrimaryPeerSubnet = newPrimaryPeerSubnet, CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); // Assert AzureBgpPeering actual = mockCommandRuntime.OutputPipeline[0] as AzureBgpPeering; Assert.AreEqual <string>(expected2.BgpPeering.PrimaryPeerSubnet, actual.PrimaryPeerSubnet); Assert.AreEqual(expected.BgpPeering.PrimaryAzurePort, actual.PrimaryAzurePort); }