public virtual ManagedInstanceKeyCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string keyName, ManagedInstanceKeyData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _managedInstanceKeyClientDiagnostics.CreateScope("ManagedInstanceKeyCollection.CreateOrUpdate"); scope.Start(); try { var response = _managedInstanceKeyRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, parameters, cancellationToken); var operation = new ManagedInstanceKeyCreateOrUpdateOperation(ArmClient, _managedInstanceKeyClientDiagnostics, Pipeline, _managedInstanceKeyRestClient.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; } }
public async virtual Task <ManagedInstanceKeyCreateOrUpdateOperation> CreateOrUpdateAsync(string keyName, ManagedInstanceKeyData 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("ManagedInstanceKeyCollection.CreateOrUpdate"); scope.Start(); try { var response = await _managedInstanceKeysRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, parameters, cancellationToken).ConfigureAwait(false); var operation = new ManagedInstanceKeyCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _managedInstanceKeysRestClient.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; } }