public async virtual Task <VirtualNetworkCreateOrUpdateOperation> CreateOrUpdateAsync(string virtualNetworkName, VirtualNetworkData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (virtualNetworkName == null) { throw new ArgumentNullException(nameof(virtualNetworkName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("VirtualNetworkContainer.CreateOrUpdate"); scope.Start(); try { var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, virtualNetworkName, parameters, cancellationToken).ConfigureAwait(false); var operation = new VirtualNetworkCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, virtualNetworkName, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <VirtualNetworkCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string virtualNetworkName, VirtualNetworkData body = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(virtualNetworkName, nameof(virtualNetworkName)); using var scope = _virtualNetworkClientDiagnostics.CreateScope("VirtualNetworkCollection.CreateOrUpdate"); scope.Start(); try { var response = await _virtualNetworkRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, virtualNetworkName, body, cancellationToken).ConfigureAwait(false); var operation = new VirtualNetworkCreateOrUpdateOperation(ArmClient, _virtualNetworkClientDiagnostics, Pipeline, _virtualNetworkRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, virtualNetworkName, body).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }