/// <summary> /// The DeleteBlobsAsync operation marks the specified blobs for /// deletion. The blobs are later deleted during garbage collection. /// All of the deletions are sent as a single batched request. /// </summary> /// <param name="blobUris">URIs of the blobs to delete.</param> /// <param name="snapshotsOption"> /// Specifies options for deleting blob snapshots. /// </param> /// <param name="async"> /// Whether to invoke the operation asynchronously. /// </param> /// <param name="cancellationToken"> /// Optional <see cref="CancellationToken"/> to propagate notifications /// that the operation should be cancelled. /// </param> /// <returns> /// The <see cref="Response"/>s for the individual Delete operations. /// </returns> /// <remarks> /// A <see cref="RequestFailedException"/> will be thrown if /// a failure to submit the batch occurs. Individual sub-operation /// failures will be wrapped in an <see cref="AggregateException"/>. /// </remarks> internal async Task <Response[]> DeleteBlobsInteral( IEnumerable <Uri> blobUris, DeleteSnapshotsOption snapshotsOption, bool async, CancellationToken cancellationToken) { blobUris = blobUris ?? throw new ArgumentNullException(nameof(blobUris)); var responses = new List <Response>(); // Create the batch BlobBatch batch = CreateBatch(); foreach (Uri uri in blobUris) { responses.Add(batch.DeleteBlob(uri, snapshotsOption)); } // Submit the batch await SubmitBatchInternal( batch, true, async, cancellationToken) .ConfigureAwait(false); return(responses.ToArray()); }
/// <summary> /// The DeleteBlobsAsync operation marks the specified blobs for /// deletion. The blobs are later deleted during garbage collection /// which could take several minutes. /// All of the deletions are sent as a single batched request. /// </summary> /// <param name="blobUris">URIs of the blobs to delete.</param> /// <param name="snapshotsOption"> /// Specifies options for deleting blob snapshots. /// </param> /// <param name="async"> /// Whether to invoke the operation asynchronously. /// </param> /// <param name="cancellationToken"> /// Optional <see cref="CancellationToken"/> to propagate notifications /// that the operation should be cancelled. /// </param> /// <returns> /// The <see cref="Response"/>s for the individual Delete operations. /// </returns> /// <remarks> /// A <see cref="RequestFailedException"/> will be thrown if /// a failure to submit the batch occurs. Individual sub-operation /// failures will be wrapped in an <see cref="AggregateException"/>. /// </remarks> internal async Task <Response[]> DeleteBlobsInteral( IEnumerable <Uri> blobUris, DeleteSnapshotsOption snapshotsOption, bool async, CancellationToken cancellationToken) { DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(BlobBatchClient)}.{nameof(DeleteBlobs)}"); try { scope.Start(); blobUris = blobUris ?? throw new ArgumentNullException(nameof(blobUris)); var responses = new List <Response>(); // Create the batch BlobBatch batch = CreateBatch(); foreach (Uri uri in blobUris) { responses.Add(batch.DeleteBlob(uri, snapshotsOption)); } // Submit the batch await SubmitBatchInternal( batch, true, async, cancellationToken) .ConfigureAwait(false); return(responses.ToArray()); } catch (Exception ex) { scope.Failed(ex); throw; } finally { scope.Dispose(); } }