ADF Pipeline to Split an a JSON File with array of objects into seperate items in cosmos db

245 Views Asked by At

I am creating a pipeline for the first time. The requirement is to fetch a JSON file with an array of objects. Split the array and save each object as a separate item in the cosmos DB.

In pipeline I am using CopyData Activity. And providing the source as JSON File and using cosmos db dataset in Sink.

I am stuck with mapping the data. Since I have given the [0] array. All the values in db gets saved with same value. I am not sure how to map the value dynamically. Can someone assist if I there is a way to map dynamically based on the number of objects in the array. Or if I can use any other Activities.

Below is the JSON Data format.

{
"d": {
    "results": [
        {
            "OrderDescription": "abc",
            "SalesManager": "abc",
            "ProjectCoordinator": "",
            "CustomerNumber": "",
            "CustomerName": "",
            "CustomerStreetAddress": "",
            "CustomerCity": "",
            "CustomerState": "",
            "CustomerZiip": "",
            "FacilityName": "",
            "ShipToNumber": "",
            "ShipToName": ""
        },
        {
            "OrderDescription": "abc",
            "SalesManager": "abc",
            "ProjectCoordinator": "",
            "CustomerNumber": "",
            "CustomerName": "",
            "CustomerStreetAddress": "",
            "CustomerCity": "",
            "CustomerState": "",
            "CustomerZiip": "",
            "FacilityName": "",
            "ShipToNumber": "",
            "ShipToName": ""
        },
        {
            "OrderDescription": "abc",
            "SalesManager": "abc",
            "ProjectCoordinator": "",
            "CustomerNumber": "",
            "CustomerName": "",
            "CustomerStreetAddress": "",
            "CustomerCity": "",
            "CustomerState": "",
            "CustomerZiip": "",
            "FacilityName": "",
            "ShipToNumber": "",
            "ShipToName": ""
        }
    ]
}

}

Mapping

1

There are 1 best solutions below

1
Sahaduna On

I found solution for the above question. Hope it helps someone.

Made few changes in the way of mapping.

Solution