How to insert item in CosmosDB(SQL API) from using Azure Data Factory activity

Viewed 71

I have an ADF pipeline which is iterating over a set of files, performing various operations and I have an Azure CosmosDB (SQL API) instance where I would like to insert the name of file and a timestamp, mainly to keep track on which files have been already processed and which not, but in the future I might want to add some other bits of data related to each file.

What I have is my CosmosDB

enter image description here

And currently I am trying to utilice the Copy Data Activity for the insert part.

One problem that I have is that this particular activity expects source while at this point I have only the filename. In theory it was an option to use the Blob Storage from where I read the file at the beginning, but since the Blob Storage is set to store binary files I got the following error if I try to use it as source

enter image description here

Because of that I created a dummy CosmosDB Linked service, but I have several issues with this approach:

  • Generally the idea for dummy source is not very appealing to me
  • I haven't find a lot of information on the topic but it seems that if I want to use something in the Sink I need to SELECT from the source
  • Even though I have selected a value for the id the item is not saved with the selected value from the Source query, but as you can see from the first screenshot I got a GUID and only the name is as I want it.

enter image description here

So my questions are two. I just learn ADF but this approach doesn't look like the proper way to insert item into CosmosDB from activity, so a better/more common approach would be appreciated. If there is not better proposal, how can I at least apply my own value for the id column? If I create the item in the CosmosDB GUI and save it from there, as you can see I am able to use the filename as id which for now seems like a good idea to me, but I wasn't able to add custom value (string or int) when I was trying through the activity, so how can I achieve this?

This is how my Sink looks like

enter image description here

0 Answers
Related