Sunday, January 19, 2020

Data Platform Tips 53 - Time to Live (TTL) in Azure Cosmos DB

Azure Cosmos DB provides the ability to remove items from the container after a defined period of time by configuring the Time to Live setting. TTL can be set at container or individual item level. The time to live value is set in seconds, and calculated as a delta from the time that an item was last modified.

Configure TTL on Container


a) Log on to the Azure Portal

b) Select the provisioned Azure Cosmos DB or provision a new one.

c) Navigate to Data Explorer and select the Container as shown below and click on "Settings" to find the TTL setting.


























d) Set the TTL to 3600 seconds and click on "Save".



















Configure TTL on an item


a) Log on to the Azure Portal

b) Select the provisioned Azure Cosmos DB or provision a new one.

c) Set the TTL for the container as shown above.

c) Navigate to Data Explorer and select the Container and the Item for which you need to add TTL and include the "ttl": 10, to the item JSON where (10 is the TTL value in seconds)


No comments:

Post a Comment