public async virtual Task <SnapshotCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string snapshotName, SnapshotData snapshot, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(snapshotName, nameof(snapshotName)); if (snapshot == null) { throw new ArgumentNullException(nameof(snapshot)); } using var scope = _snapshotClientDiagnostics.CreateScope("SnapshotCollection.CreateOrUpdate"); scope.Start(); try { var response = await _snapshotRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, snapshotName, snapshot, cancellationToken).ConfigureAwait(false); var operation = new SnapshotCreateOrUpdateOperation(ArmClient, _snapshotClientDiagnostics, Pipeline, _snapshotRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, snapshotName, snapshot).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <SnapshotResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string snapshotName, SnapshotData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(snapshotName, nameof(snapshotName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _snapshotClientDiagnostics.CreateScope("SnapshotCollection.CreateOrUpdate"); scope.Start(); try { var response = await _snapshotRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, snapshotName, data, cancellationToken).ConfigureAwait(false); var operation = new ComputeArmOperation <SnapshotResource>(new SnapshotOperationSource(Client), _snapshotClientDiagnostics, Pipeline, _snapshotRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, snapshotName, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }