public virtual NetworkProfileCreateOrUpdateOperation CreateOrUpdate(string networkProfileName, NetworkProfileData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (networkProfileName == null) { throw new ArgumentNullException(nameof(networkProfileName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("NetworkProfileCollection.CreateOrUpdate"); scope.Start(); try { var response = _restClient.CreateOrUpdate(Id.ResourceGroupName, networkProfileName, parameters, cancellationToken); var operation = new NetworkProfileCreateOrUpdateOperation(Parent, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <NetworkProfileCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string networkProfileName, NetworkProfileData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(networkProfileName, nameof(networkProfileName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _networkProfileClientDiagnostics.CreateScope("NetworkProfileCollection.CreateOrUpdate"); scope.Start(); try { var response = await _networkProfileRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, networkProfileName, parameters, cancellationToken).ConfigureAwait(false); var operation = new NetworkProfileCreateOrUpdateOperation(ArmClient, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }