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