public async virtual Task <DiskCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string diskName, DiskData disk, CancellationToken cancellationToken = default) { if (diskName == null) { throw new ArgumentNullException(nameof(diskName)); } if (disk == null) { throw new ArgumentNullException(nameof(disk)); } using var scope = _clientDiagnostics.CreateScope("DiskCollection.CreateOrUpdate"); scope.Start(); try { var response = await _disksRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, diskName, disk, cancellationToken).ConfigureAwait(false); var operation = new DiskCreateOrUpdateOperation(this, _clientDiagnostics, Pipeline, _disksRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, diskName, disk).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <ArmOperation <Disk> > CreateOrUpdateAsync(bool waitForCompletion, string diskName, DiskData disk, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diskName, nameof(diskName)); Argument.AssertNotNull(disk, nameof(disk)); using var scope = _diskClientDiagnostics.CreateScope("DiskCollection.CreateOrUpdate"); scope.Start(); try { var response = await _diskRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, diskName, disk, cancellationToken).ConfigureAwait(false); var operation = new ComputeArmOperation <Disk>(new DiskOperationSource(Client), _diskClientDiagnostics, Pipeline, _diskRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, diskName, disk).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }