Azure Cosmo DB partitioning
While preparing for AZ-303 exam, I was using couple of resources:
I was stuck answering the questions about inserting items in the CosmoDB, using SQL API. So in the end, I decided to use the real Cosmo DB instance and did exactly the same, what was asked in the questions. The outcome is that the answers in both mentioned resources were wrong.
idfor an item is a “unique name in a logical partition”, which could be defined by System or User. So if you do not defined it, it will be AUTO-GENERATED.
- “Uniqueness of the
idproperty is only enforced within each logical partition. Multiple documents can have the same
idproperty with different partition key value”. If there is already an item in a particular logical partition, which is defined by partition key, with the same
id, you won’t be able to add a new item with the same id and partition key.
For example, you have a container with a partition key /id and there is an item
You won’t be able to add
The error would be “Entity with the specified id already exists in the system”.