Jean-Paul Smit
Jean-Paul Smit

Reputation: 338

Copy data from Cosmos Db to table storage fails on custom RowKey

I'm trying to get a very simple data migration to work, where I want 3 fields from Cosmos Db documents to be inserted as entities in Table Storage. The challenge seems to be in the fact that I want an Id from the document, also to be the value of the partition key and row key. I took the Copy data activity, defined Cosmos Db as source, table storage as sink and defined mappings to get the right data into the right field.

enter image description here

In the sink you can specify what to do with partition key and row key. When I specify the partition key to be the id from the document, it works.

However, when I do the same for row key (instead of a generated identifier), I get this error "The specified AzureTableRowKeyName 'UserId' doesn't exist in the source data".

enter image description here

enter image description here

The weird thing is that there appears to be no problem regarding the partition key for that value.

Any one who can point me in the right direction?

Upvotes: 0

Views: 747

Answers (2)

Jean-Paul Smit
Jean-Paul Smit

Reputation: 338

Thanks to @BhanunagasaiVamsi-MT for pointing me in the right direction. For completeness sake, I'm dropping my solution here, although the link in that post also explains it.

You need to:

  • specify additional columns, based on the source data
  • select these colums as rowkey or partitionkey in the sink
  • assign the additional fields to rowkey and partitionkey in the mapping (feels like a duplicate thing to do, but if you don't you get the error mentioned in the question) specify additional columns select colums as rowkey or partitionkey assign the additional fields to rowkey and partitionkey

Upvotes: 1

Vamsi Bitra
Vamsi Bitra

Reputation: 2739

I tried to reproduce the same in my environment and got the same error as below:

Ref1

If I specify unique identifier its working fine.

ref2

Note: Specify the name of the column whose column values are used as the row key. If not specified, use a GUID for each row

Ref3

For more information refer this Microsoft documentation.

Upvotes: 0

Related Questions