A sessions container in Azure Cosmos DB for NoSQL has DefaultTimeToLive set to 86400. Some time ago, the team exempted item session-77 from expiration by setting its ttl to -1. That business account has now closed. You have the following requirements:
session-77must follow the container's default lifetime again, including any new value the team sets for the default later.- The expiration behavior of all other items in the container must not change.
- The item must use a value or structure that Azure Cosmos DB supports for item TTL.
What should you do?
An item's ttl property overrides the container default, and when the property is absent the container's DefaultTimeToLive applies. Removing the property is therefore the only option here that ties session-77 to the default, including future changes to it. Null is accepted on the container but not on an item. Setting the container default to -1 would stop expiration for items that inherit it and would leave session-77 exempt.
- Not correct: Set the container's DefaultTimeToLive to -1. With -1 on the container, items without their own ttl stop expiring. Every session that relies on the 24-hour default would become permanent, and session-77 would still not expire.
- Not correct: Set the ttl property of session-77 to 86400. An item ttl overrides the container's DefaultTimeToLive. The item would keep a fixed 86400-second lifetime and would not pick up a later change to the container default.
- Not correct: Set the ttl property of session-77 to null. Null is a valid value only on the container, where it turns TTL off. On an item, null is not supported; an item accepts only -1 or a positive whole number of seconds no larger than 2,147,483,647.
- Correct: Remove the ttl property from session-77. An item without a ttl property uses the container's DefaultTimeToLive, so it follows the current default and any later change to it. No other item is affected.