void deleteMetadata(List<CloudBlobMetadata> blobMetadataList) throws CosmosException {
    String partitionPath = blobMetadataList.get(0).getPartitionId();
    if (bulkDeleteEnabled) {
      for (List<CloudBlobMetadata> batchOfBlobs : Utils.partitionList(blobMetadataList, purgeBatchSize)) {
        // Retry each batch since there may be many of them.
        try {
          requestAgent.doWithRetries(() -> {
            try {
              return bulkDeleteMetadata(batchOfBlobs);
            } catch (CosmosException cex) {
              throw new CloudStorageException("BulkDelete failed", cex, cex.getStatusCode(), true,
                  cex.getRetryAfterDuration().toMillis());
            }
          }, "BulkDelete", partitionPath);
        } catch (CloudStorageException cse) {
          if (cse.getCause() != null && cse.getCause() instanceof CosmosException) {
            throw (CosmosException) cse.getCause();
          } else {
            throw new IllegalStateException("Unexpected error in BulkDelete partition " + partitionPath,
                cse.getCause());
          }
        }
      }
    } else {
      List<CompletableFuture<Boolean>> operationFutures = new ArrayList<>();
      blobMetadataList.forEach(metadata -> operationFutures.add(deleteMetadataAsync(metadata)));
      try {
        // Wait for all async delete operations to complete.
        CompletableFuture.allOf(operationFutures.toArray(new CompletableFuture<?>[0])).join();
      } catch (CompletionException ex) {
        Exception e = Utils.extractFutureExceptionCause(ex);
        if (e instanceof CosmosException) {
          throw (CosmosException) e;
        } else {
          throw new RuntimeException(e);
        }
      }
    }
  }
Delete the blob metadata documents in the CosmosDB collection.
@param blobMetadataList the list of blob metadata documents to delete.
@throws CosmosException if the operation failed.
ambry-cloud/src/main/java/com/github/ambry/cloud/azure/CosmosDataAccessor.java