Cosmos DB - Bulk Import (single partition collections) with customized partition key

一个人想着一个人 提交于 2019-12-23 04:39:04

问题


I am trying to migrate some data from a JSON file to Cosmos DB using Data Migration Tool, when I tried to define the partition key with either single or a combination of my column name, every time I am getting undefined partition key after migration, how could I correct this issue?

Note here I'll have to use Bulk import (single partition collections) options, because I need to execute my customized stored procedure for nested array import, I cannot use sequential record import as I know the same partition function works very well there.

So here I am setting my partition key to be "/item/vid":

After migration, my collection shows "_partitionKey" instead of "/item/vid" there:


回答1:


If you use Bulk import with migration tool, the partition key setting is for more than collection scenario.Please see the statement in this link:

When you import to more than one collection, the import tool supports hash-based sharding. In this scenario, specify the document property you wish to use as the Partition Key. (If Partition Key is left blank, documents are sharded randomly across the target collections.)

Back to your requirement,you could use Sequential Record Import.

You need to create collection first and set the partition key as /item/vid.

My test json file:

Result:



来源:https://stackoverflow.com/questions/57013043/cosmos-db-bulk-import-single-partition-collections-with-customized-partition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!