Share via

Inserting a JSON list in Cosmos DB

Devashish Parmar (BLR GSS) 86 Reputation points
Dec 20, 2022, 12:51 PM

I am using ADF to load documents to Cosmos DB. The challenge is I want to have a sub JSON format inside a list i.e. [ ].

Below is a sample format.

{
"paymentFrequency": "SP",
"address": [
{
"street1": "GA04230-US",
"street2": 0,
"street3": "359668276007920",
}
],
"partitionKey": "partitionKey1",
}

Note the values inside 'address' is a list.

Can you help me achieve it using Azure Data FActory (ADF)?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,816 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,400 questions
0 comments No comments
{count} votes

Accepted answer
  1. ShaikMaheer-MSFT 38,521 Reputation points Microsoft Employee
    Dec 21, 2022, 6:44 AM

    Hi @Devashish Parmar (BLR GSS) ,

    Thank you for posting query in Microsoft Q&A Platform.

    You can consider using flatten transformation to flatten the array(list). Click here to know more about flatten transformation.

    You can consider checking below video as well about flatten transformation.
    Flatten Transformation in Mapping Data Flow in Azure Data Factory

    Kindly check below where I tried same
    Source File and Source Transformation in dataflow.
    272853-image.png

    Flatten Transformation:
    272871-image.png

    After loading data to sink storage using Sink transformation
    272783-image.png

    Hope this helps. Please let me know if any further queries.

    ----------------

    Please consider hitting Accept Answer button. Accepted answers help community as well.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.