public async virtual Task <LocalUserCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string username, LocalUserData properties, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(username, nameof(username)); if (properties == null) { throw new ArgumentNullException(nameof(properties)); } using var scope = _localUserClientDiagnostics.CreateScope("LocalUserCollection.CreateOrUpdate"); scope.Start(); try { var response = await _localUserRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, username, properties, cancellationToken).ConfigureAwait(false); var operation = new LocalUserCreateOrUpdateOperation(ArmClient, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <LocalUserResource> > UpdateAsync(WaitUntil waitUntil, LocalUserData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _localUserClientDiagnostics.CreateScope("LocalUserResource.Update"); scope.Start(); try { var response = await _localUserRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); var operation = new StorageArmOperation <LocalUserResource>(Response.FromValue(new LocalUserResource(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }