Hi
Aditya Kshirsagar •
Welcome to Microsoft Q&A forum and thanks for using Azure Services.
As I understand, you are having update issue via Python SDK into Azure Cosmos DB containers records.
Could you please share the sample code used?
Also note that when you are using Unique Keys, the check is related to having 2 different documents with the same Unique Key value. The Cosmos DB output binding will try to do an Upsert operation, so if the document already exists, it will try to update it, if not, create it. This error should appear if you are trying to insert a document with different id, but same Unique Key than another existing document.
Whenever you want to update the record if already existing in cosmosDB from Azure trigger function, below points should be taken care.
- Check for the element named id existing in DB collection for a Unique key
- The id should be same for the data which is updating for a Unique key while upserting.
If the element id is not same then, while upserting cosmos will assign a new value for that element and we will have 2 entry for a Unique key with different ids and throw the above error.
Additionally, check the Consistency Level, Partition Key, Retry Policy and Logs to help in troubleshooting.
Awaiting your reply if above helps else we will continue to engage on the question.
Thanks.