public long deprecateContainers(Set<CosmosContainerDeletionEntry> deprecatedContainers) throws CosmosException {
    long latestContainerDeletionTimestamp = -1;

    CosmosAsyncContainer cosmosContainer = cosmosAsyncDatabase.getContainer(cosmosDeletedContainerCollection);
    CosmosContainerResponse cosmosContainerResponse = cosmosContainer.read().block();
    if (cosmosContainerResponse == null) {
      throw new IllegalStateException(
          "CosmosDB container for storing deprecated Ambry containers not found: " + cosmosDeletedContainerCollection);
    }

    for (CosmosContainerDeletionEntry containerDeletionEntry : deprecatedContainers) {
      try {
        executeCosmosAction(
            () -> cosmosContainer.createItem(containerDeletionEntry, new PartitionKey(containerDeletionEntry.getId()),
                new CosmosItemRequestOptions()).block(), azureMetrics.containerDeprecationDocumentCreateTime);
        if (containerDeletionEntry.getDeleteTriggerTimestamp() > latestContainerDeletionTimestamp) {
          latestContainerDeletionTimestamp = containerDeletionEntry.getDeleteTriggerTimestamp();
        }
      } catch (CosmosException cex) {
        if (cex.getStatusCode() == HttpConstants.StatusCodes.CONFLICT) {
          // If the cosmos exception is due to container being already deprecated, continue.
          logger.info("Container with accountid {} and containerid {} already deprecated. Skipping.",
              containerDeletionEntry.getAccountId(), containerDeletionEntry.getContainerId());
        } else {
          throw cex;
        }
      }
    }
    return latestContainerDeletionTimestamp;
  }
Add the {@link CosmosContainerDeletionEntry} for newly deprecated {@link Container}s to cosmos table.
@param deprecatedContainers {@link Set} of deleted {@link CosmosContainerDeletionEntry}s.
@return the max deletion trigger time of all the added containers to serve as checkpoint for future update.
@throws CosmosException in case of any error.
ambry-cloud/src/main/java/com/github/ambry/cloud/azure/CosmosDataAccessor.java