public async virtual Task <ExpressRoutePortCreateOrUpdateOperation> CreateOrUpdateAsync(string expressRoutePortName, ExpressRoutePortData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (expressRoutePortName == null) { throw new ArgumentNullException(nameof(expressRoutePortName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("ExpressRoutePortContainer.CreateOrUpdate"); scope.Start(); try { var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, expressRoutePortName, parameters, cancellationToken).ConfigureAwait(false); var operation = new ExpressRoutePortCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, expressRoutePortName, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ExpressRoutePortCreateOrUpdateOperation CreateOrUpdate(string expressRoutePortName, ExpressRoutePortData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (expressRoutePortName == null) { throw new ArgumentNullException(nameof(expressRoutePortName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("ExpressRoutePortCollection.CreateOrUpdate"); scope.Start(); try { var response = _expressRoutePortsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, expressRoutePortName, parameters, cancellationToken); var operation = new ExpressRoutePortCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _expressRoutePortsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, expressRoutePortName, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }