public async virtual Task <ServerKeyCreateOrUpdateOperation> CreateOrUpdateAsync(string keyName, ServerKeyData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (keyName == null) { throw new ArgumentNullException(nameof(keyName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("ServerKeyCollection.CreateOrUpdate"); scope.Start(); try { var response = await _serverKeysRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, parameters, cancellationToken).ConfigureAwait(false); var operation = new ServerKeyCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _serverKeysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ServerKeyCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string keyName, ServerKeyData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _serverKeyClientDiagnostics.CreateScope("ServerKeyCollection.CreateOrUpdate"); scope.Start(); try { var response = _serverKeyRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, parameters, cancellationToken); var operation = new ServerKeyCreateOrUpdateOperation(ArmClient, _serverKeyClientDiagnostics, Pipeline, _serverKeyRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }