Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy json data from Azure cosmos db to Azure sql using Azure Data Factory

I am using Azure Data Factory V1. We want to copy the json data stored as documents from Azure cosmos to a azure sql table, using a copy activity.

I figured out copying the data by specifying the columns in sql table to match the property names from json. However our goal is to copy the entire json data as a single field. We are doing this for the purpose of being agnostic to the schema within the json data.

I have tried specifying a single nvarchar(max) column to store the json data, and the query on the copy activity to be "select c as "FullData" from c". But the copy activity simply generates a NULL.

I think this is because "FullData" is of type json on the document end and it is string on the sql end. I also tried to convert the json object to string within the cosmos db query. But I couldnt find any API to do so.

I know we could write a custom activity to accomplish what I want to do, but is this possible to do with ADF out of the box functionality?

like image 622
Schu Avatar asked Feb 02 '26 02:02

Schu


1 Answers

you can use the jsonPathDefinition as similar as this: "column_full": "$. "

Refer to this link on how to use jsonFormat with ADF: https://learn.microsoft.com/en-us/azure/data-factory/supported-file-formats-and-compression-codecs#json-format

like image 86
Wenbo Fu Avatar answered Feb 03 '26 16:02

Wenbo Fu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!