nerdexam
Microsoft

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.

Integrate an Azure Cosmos DB solution

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)
  • A
    3% (1)
  • B
    3% (1)
  • C
    87% (26)
  • D
    7% (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.

ATimeToLivePropertyPath to null

`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`.

BTimeToLivePropertyPath to 0

Setting `TimeToLivePropertyPath` to `0` is an invalid value for a property path and would not disable container-level TTL.

CDefaultTimeToLive to nullCorrect

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.

DDefaultTimeToLive to -1

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

#Azure Cosmos DB#.NET SDK#Time To Live (TTL)#Container configuration

Community Discussion

No community discussion yet for this question.

Full DP-420 Practice