Search code examples
azureazure-cosmosdb

Not able to upload data to cosmos using Azure UI


I want to upload the data to cosmos DB (NoSQL API). Here is my Partition key logic for the Table

partition key : /x_id/location/name unique keys : [/source, /type]

The JSON file I want to upload is

[
  {
    "x_id": "1",
    "type": "ROLL",
    "location": "10",
    "source": "A",
    "event_name": "B"
  },
  {
    "x_id": "2",
    "type": "ROLL",
    "location": "11",
    "source": "C",
    "event_name": "D"
  }
]

It's giving me the below error for saving the data

Error bulk creating items for container table_name:
 Cannot use the 'in' operator to search for 'location' in 1

But when I add single items to the same container it's working fine, but when doing bulk upload it starts giving the above error.

Option used for bulk upload : Upload Item enter image description here

Error : enter image description here

Can anyone help with this?


Solution

    • In order to create hierarchical partition key in cosmos db, /x_id/location/name click Add hierarchical partition key for adding each key in order. Since there is no column named name in the sample document shared, I replaced that with event_name.

    enter image description here

    • After creating partition key as in above image, items got uploaded without any error.

    enter image description here