I don't have access to foreach item from expression builder under data source in ADF

Viewed 71

I'm trying to save some values in a SQL table and then loop over the values to use each value as path in an OData source.

First I have defined an array where to save the values:

enter image description here

then the variable is set to @activity('Lookup1').output.value

enter image description here

Now the data is accessed from foreach. enter image description here

Inside the foreach loop I have a copy activity where the Odata source should be se as the value. But I don't have access to the item. Why is that? enter image description here

enter image description here

enter image description here

1 Answers

The above approach will work for you when debug the pipeline even through it is giving warning in the dataset.

The dataset dynamic content doesn't know about ForEach @item() at first because it belongs to pipeline dynamic content. Thats why it is giving warning in the dataset.

But at debug time, it identifies the @item() value.

Please go through the below 2 scenarios to understand it better.

Here I am using ADLS as source and target with array of files for sample and passing to the ForEach.

These are my source files.

enter image description here

I have Created an array variable with above names like ["sample1.csv","sample2.csv"] and passed to ForEach,

Using @item() in dataset:

Source dataset and target dataset.

enter image description here

enter image description here

You can see it is giving the same warning, but it will give the correct result when you debug. But in dataset preview, it will give the error.

enter image description here

Copied files to target successfully.

enter image description here

Using @item() inside ForEach using dataset parameters:

I have created the parameters and used in datasets.

Source:

enter image description here

Target:

enter image description here

Copy activity inside ForEach:

Source parameter @item():

enter image description here

sink parameter @item():

enter image description here

Files copied to target successfully.

enter image description here

Related