Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
Neka
Helper III
Helper III

How to create an array from specific JSON key values for ForEach activity.

Hello,

I have a JSON file with this structure from a CopyData activity step in my Data Factory pipeline: 

"value": [{
"id": "123",
"isReadOnly": false,
//additional key-values
}, {
"id": "1234",
"isReadOnly": false,
//additional key-values
}, {
"id": "12345",
"isReadOnly": false,
//additional key-values
},

 

I want to extract all the 'ids' and turn them into an array so that I can iterate over them in a ForEach activity in Data Factory ex. ["123","1234","12345"]. How do I accomplish this? 

 

I am very new to Data Factory so thank you for any other suggestions regarding using the ForEach to iterate over all the ids. As well, if you are able, the more detail the better. Thank you!

1 ACCEPTED SOLUTION
NandanHegde
Super User
Super User

Hey,

The output Value is by default an Array.

You can iterate over the Copy activity output directly via For each and get the ID details per iteration itself.

 

NandanHegde_0-1709004375168.png

where parameter Test value is :

[{ "id": "123", "isReadOnly": false }, { "id": "1234", "isReadOnly": false }]

 

You can use For each activity to iterate over the value directly 

NandanHegde_1-1709004440808.png

within for each, use Set variable activity to get the ID value 

 

NandanHegde_2-1709004480064.png

Output :

NandanHegde_3-1709004515730.png

 




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

View solution in original post

3 REPLIES 3
NandanHegde
Super User
Super User

Hey,

The Parameter is just an example for demonstration purpose.

If the file size is less, you can use lookup activity to read the file and use that lokup value inplace of parameter




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com
NandanHegde
Super User
Super User

Hey,

The output Value is by default an Array.

You can iterate over the Copy activity output directly via For each and get the ID details per iteration itself.

 

NandanHegde_0-1709004375168.png

where parameter Test value is :

[{ "id": "123", "isReadOnly": false }, { "id": "1234", "isReadOnly": false }]

 

You can use For each activity to iterate over the value directly 

NandanHegde_1-1709004440808.png

within for each, use Set variable activity to get the ID value 

 

NandanHegde_2-1709004480064.png

Output :

NandanHegde_3-1709004515730.png

 




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

Thank you for answering my question, but how do I make the Default Value in the Parameters my Id key from my JSON file? In your example, it looks like the JSON file has been copy pasted into default value but since I'm creating a new JSON file everytime I run copy data, how would I make sure that that new JSON file is always used? 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.