public async virtual Task <FileShareCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string shareName, FileShareData fileShare, string expand = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(shareName, nameof(shareName)); if (fileShare == null) { throw new ArgumentNullException(nameof(fileShare)); } using var scope = _fileShareClientDiagnostics.CreateScope("FileShareCollection.CreateOrUpdate"); scope.Start(); try { var response = await _fileShareRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, shareName, fileShare, expand, cancellationToken).ConfigureAwait(false); var operation = new FileShareCreateOrUpdateOperation(ArmClient, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <FileShare> > CreateOrUpdateAsync(WaitUntil waitUntil, string shareName, FileShareData fileShare, string expand = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(shareName, nameof(shareName)); Argument.AssertNotNull(fileShare, nameof(fileShare)); using var scope = _fileShareClientDiagnostics.CreateScope("FileShareCollection.CreateOrUpdate"); scope.Start(); try { var response = await _fileShareRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, shareName, fileShare, expand, cancellationToken).ConfigureAwait(false); var operation = new StorageArmOperation <FileShare>(Response.FromValue(new FileShare(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }