DP-420 · Question #123
You have an Azure Cosmos DB for NoSQL account named account1. You need to create a container named Container1 in account1 by using the Azure Cosmos DB .NET SDK. The solution must ensure that the…
The correct answer is C. DefaultTimeToLive to null. To ensure items in an Azure Cosmos DB container never expire, you must set the DefaultTimeToLive property of the container to null when creating it via the .NET SDK.
Question
You have an Azure Cosmos DB for NoSQL account named account1. You need to create a container named Container1 in account1 by using the Azure Cosmos DB .NET SDK. The solution must ensure that the items in Container1 never expire. What should you set?
Options
- ATimeToLivePropertyPath to null
- BTimeToLivePropertyPath to 0
- CDefaultTimeToLive to null
- DDefaultTimeToLive to -1
How the community answered
(30 responses)- A3% (1)
- B3% (1)
- C87% (26)
- D7% (2)
Why each option
To ensure items in an Azure Cosmos DB container never expire, you must set the `DefaultTimeToLive` property of the container to `null` when creating it via the .NET SDK.
`TimeToLivePropertyPath` defines a property within an item that contains its TTL value, it does not disable TTL for the entire container when set to `null`.
Setting `TimeToLivePropertyPath` to `0` is an invalid value for a property path and would not disable container-level TTL.
Setting the `DefaultTimeToLive` property to `null` for a container explicitly disables the Time-to-Live (TTL) feature for that container. This ensures that items will never expire by default, fulfilling the requirement for all items in the container.
Setting `DefaultTimeToLive` to `-1` enables TTL but sets a default of "never expire"; however, an item-level TTL could still override this. Setting to `null` truly disables TTL at the container level, preventing any expiration.
Concept tested: Azure Cosmos DB Time-to-Live (TTL) configuration
Source: https://learn.microsoft.com/en-us/azure/cosmos-db/time-to-live
Topics
Community Discussion
No community discussion yet for this question.