Currently, my data is in azure cosmos db (DocumentDB) with wrong or un-optimized partition key. Now I want to update partition key and re distribute my data but not able to figure it out. How can I do it?
Selecting your partition key is a simple but important design choice in Azure Cosmos DB. Once you select your partition key, it is not possible to change it in-place. If you need to change your partition key, you should move your data to a new container with your new desired partition key.
If you do need to change a partition key, you need to create a new container and migrate your data to that one. A partition key consists of a path. This can be something like /firstname or /name/first, or a nested property, as long as it is a JSON property from the documents in the container.
Note that you can't change the partition key of a container. If you do need to change it, you need to migrate the container data to a new container with the correct key.
Now I want to update partition key and re distribute my data but not able to figure it out how can I do it.
Currently it is not possible to update the partition key attribute in a collection or change partition key value in a document.
If you want to change the partition key attribute, you would need to delete that collection and create a new one with correct partition key attribute.
Similarly, if you wish to update the partition key value in a document you must first delete the document and create a new document with correct partition key value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With