public virtual async Task <ArmOperation <ServerKey> > CreateOrUpdateAsync(WaitUntil waitUntil, string keyName, ServerKeyData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); Argument.AssertNotNull(parameters, nameof(parameters)); using var scope = _serverKeyClientDiagnostics.CreateScope("ServerKeyCollection.CreateOrUpdate"); scope.Start(); try { var response = await _serverKeyRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, parameters, cancellationToken).ConfigureAwait(false); var operation = new SqlArmOperation <ServerKey>(new ServerKeyOperationSource(Client), _serverKeyClientDiagnostics, Pipeline, _serverKeyRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, parameters).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ServerKeyCreateOrUpdateOperation CreateOrUpdate(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 = _serverKeysRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, parameters, cancellationToken); var operation = new ServerKeyCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _serverKeysRestClient.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; } }