Why there is no upsert key for cosmos Db container

Michael M 85 Reputation points
2024-05-17T18:43:35.1466667+00:00

Hello,

Using the copy activity- Azure SQL to cosmos DB there is no upsert key. Is this expected behavior or this is a product limitation?

Appriciate your help!

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,844 questions
0 comments No comments
{count} votes

Accepted answer
  1. BhargavaGunnam-MSFT 28,066 Reputation points Microsoft Employee
    2024-05-17T19:44:46.78+00:00

    Hello Michael M,

    Welcome to the Microsoft Q&A forum.

    Azure Synapse's Copy Data activity does not provide an option to specify the unique key column for upsert operations into Azure Cosmos DB.

    The reason behind this is:

    The id field in Cosmos DB item acts as the key column to perform update or delete or upsert operations. When performing update or delete actions, specifying the partition key is mandatory. This is because the service uses the partition key to search for the id field value and perform the update or delete operation accordingly.

    The unique key violation error you're encountering suggests that the data being copied contains duplicate values for the id field defined in your Cosmos DB container.

    Please ensure that the data in Azure SQL does not contain duplicates for the fields that form the unique key in Cosmos DB.

    I hope this answers your question.

    Please let me know if you have any further questions.

    If this answers your question, please consider accepting the answer by hitting the Accept answer and up-vote as it helps the community look for answers to similar questions.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful