Azure/azure-cosmos-python

Possible to change collection ttl after creation?

Closed this issue · 1 comments

My application relies heavily on pydocumentdb to interact with cosmos. We're looking for the ability to change TTL of a collection after its creation. We already know how to query the collection offer and change throughput by placing in an replacement offer. But I don't see a field for TTL there.

Is this supported? If not, what's a reasonable workaround?

Thank you!

Hi @ElvaHuang
You can replace the collection definition to modify its TTL value:
coll = client.ReadCollection(COLLECTION_LINK)
coll['defaultTtl'] = NEW_TTL_VALUE
client.ReplaceCollection(COLLECTION_LINK, coll)