Hi @Daniel Ivanov,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
As I understand it, you're encountering an issue with enabling TTL in Azure Cosmos DB for MongoDB. The message in the screenshot indicates that a TTL index needs to be created.
Here are a few additional things to check and try:
- Make sure the TTL index is created correctly on the _ts field. This command should be run in a MongoDB shell or a tool like MongoDB Compass or Studio 3T.
db.collection.createIndex({ "_ts": 1 }, { expireAfterSeconds: 3600 })
- After running the command, verify that the index has been created and ensure that the _ts index with the expireAfterSeconds option is listed.
db.collection.getIndexes()
- If there are any errors during index creation, they should be displayed in the shell or tool you are using. Common issues include syntax errors or unsupported options.
- Sometimes, the Azure portal might not fully support certain operations. Using native MongoDB tools like the MongoDB shell, MongoDB Compass, or Studio 3T is recommended.
- Ensure that your documents have the _ts field populated. This field is a system property in Azure Cosmos DB that stores the timestamp of the document’s last modification.
Here is a similar thread that might be helpful to you.
https://zcusa.951200.xyz/en-us/answers/questions/699608/azure-cosmosdb-api-for-mongodb-ttl-index-failed-to
For more information, please refer the documents:
https://zcusa.951200.xyz/en-us/azure/cosmos-db/mongodb/time-to-live?source=recommendations
https://zcusa.951200.xyz/en-us/azure/cosmos-db/nosql/time-to-live?source=recommendations
https://zcusa.951200.xyz/en-us/azure/cosmos-db/mongodb/indexing?source=recommendations
Hope this helps. Do let us know if you any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.