Robert Riley
Robert Riley

Reputation: 406

Azure Data Factory Lookup and For Each

I have a Data Factory Pipeline that I want to have iterate through the rows of a SQL Lookup activity. I have narrowed the query down to three columns and 500 rows.

I understand that to reference a value in the table I use:

@{activity('lookupActivity').output.value[row#].colname}

However, the for each needs to have something to iterate over. My first guess is to set some array variable to the rows of the returned sql query. So what do I set that variable to?

@{activity('lookupActivity').output.value?

Lastly, it looks like almost all data is represented as a json in ADF, is this true? And how could I view the output of this look up as a json so I can understand what my dynamic content needs to look like?

Upvotes: 5

Views: 26388

Answers (2)

Jason Welch
Jason Welch

Reputation: 986

You're right that everything (nearly) is JSON. (Exception: Azure Data Factory v2: Activity execute pipeline output

So you can put your @activity('lookupActivity').output.value which is an array into the foreach activity on the settings tab, like this

enter image description here

Then inside your foreach loop, you reference the current value of one of the columns as @item().colname.

Upvotes: 13

Nathan
Nathan

Reputation: 45

You can use the output value to for each activity and go through one at a time. You can do sequential or parallel depending on your needs.

Upvotes: 1

Related Questions