1

How to Read and write array Output from activity(row outputs) as input to foreach loop in Azure Data Factory?

4
  • Hi@Being Real, you want to pass array variable to forEach in ADF ? Commented Jul 13, 2022 at 10:28
  • @RakeshGovindula-MT yes I want to access the previous activity output( i made o/p as an array) and do manipulations inside foreach loop How can I aceess these values in foreach loop Commented Jul 13, 2022 at 10:58
  • @RakeshGovindula-MT Thank yu,How can i set the value of new_values_array in variables inside foreach loop Eg(1,2,3,4) i need to set v=1,q=2,etc like that Commented Jul 13, 2022 at 12:37
  • You just use the @item() syntax within the For Each activity. I would need to see some sample data and expected results for a more complete answer. Commented Jul 13, 2022 at 12:58

1 Answer 1

1

How can i set the value of new_values_array in variables inside foreach loop Eg(1,2,3,4) i need to set v=1,q=2,etc like that

To get the Result array like a=1,b=2, you need another array for the letters.

Here I am using 3 arrays and generating the result array with append activity.

numbers_array -> for the numbers [1,2,3,4](This is your output array from previous activity).

letters -> for the letters ["a","b","c","d"].

index_array -> extra array of indexes for using two arrays inside Foreach using their indexes. @range(0,length(variables('numbers_array'))) results [0,1,2,3].

new_values_array -> Result array in append activity inside ForEach.

numbers_array:

enter image description here

letters array:

enter image description here

index_array:

enter image description here

In ForEach, check the Sequential and give the index_array as @variables('index_array') because by using this array we are getting the values of multiple arrays inside ForEach.

enter image description here

Inside ForEach use append and give the below dynamic content for new_values_array.

@concat(variables('letters')[item()],'=',variables('numbers_array')[item()])

enter image description here

Result in another array(Optional step, only for showing output here):

enter image description here

Output after pipeline execution:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.