1
votes

I am using CosmosDb for a project, and was first trying the Document-db java SQL API. With that API I can set item-level TTLs right on the Document itself. Ex.

Document document = new Document(new Gson().toJson(testObject));
    document.setTimeToLive(10); // Time to live 10 seconds
    documentClient.createDocument(documentCollection.getSelfLink(), document, null,
        false).getResource();

However, I am also interested in using the Table API. I could not find anything in the documentation about setting item-level TTL. https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-java I am using https://github.com/Azure/azure-storage-java version 8.0.0 https://mvnrepository.com/artifact/com.microsoft.azure/azure-storage

Is it possible to do this, or at least set a server-side TTL for all items in a table? Thanks!

1
TTL can be enabled/disabled at the container level in the Azure Portal across all Cosmos DB APIs. Document level TTL depends upon the SDK you are using. Can you detail the SDK you are working with.Mike Ubezzi
As long as the SDK supports TTL, which Java and .NET do, you can use those methods at the document level. I could not find this functionality in NodeJS nor Python SDKs.Mike Ubezzi

1 Answers

2
votes

Today, Table API does not expose any TTL feature, so unfortunately you cannot use TTL with the Table API, even though Cosmos supports it under the covers.