0

Does Azure Cosmos DB support setting a TTL for a Table? How can we set that from code while creating the table with CreateIfNotExists call? (I am using Microsoft.Azure.Cosmos.Table) I am not looking for setting it per-item basis (I found in feature requests that it is not available as a feature yet) and want it to be applicable on all entries in the table.

Sayantan Ghosh
  • 998
  • 2
  • 9
  • 29
  • Does this [link](https://stackoverflow.com/questions/62550860/is-there-a-way-to-programmatically-change-ttl-on-a-cosmos-db-table) answer your question? – Steve Johnson Jul 13 '20 at 01:05

1 Answers1

0

It is available in the DOCS

// Create a new container with TTL enabled and a 90 day expiration
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.Id = "myContainer";
collectionDefinition.PartitionKey.Paths.Add("/myPartitionKey");
collectionDefinition.DefaultTimeToLive = 90 * 60 * 60 * 24 // expire all documents after 90 days
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396