vikas kumar
vikas kumar

Reputation: 13

can we pass pipeline variable inside the for each loop or other iterative activities

I am using azure data factory to download a file using the copy activity. The copy activity is called inside the for each activity. I need to pass a variable that can be used in the copy activity .

But I get an error saying "The output of variable <variable name> can't be referenced since it is not a variable of the current pipeline".

Upvotes: 1

Views: 2592

Answers (2)

MartinJaffer-MSFT
MartinJaffer-MSFT

Reputation: 713

Before you can use a variable, you must first declare it in the scopt of the pipeline.

  1. Go to pipeline view
  2. Click in empty whitespace, so you are not focused on any activity
  3. Select the Variable tab
  4. Make you variable

Please be aware that when setting the value of a variable, it cannot reference itself (X=X+1). I.E. You cannot use a variable as a counter during a for-each loop. Pipeline variable declaration

Upvotes: 1

Jay Gong
Jay Gong

Reputation: 23782

You could try to use Set Variable Activity with Copy Activity in the ForEach Activity.

Set Variable Activity:

Use the Set Variable activity to set the value of an existing variable of type String, Bool, or Array defined in a Data Factory pipeline.

enter image description here

Then you could use it with dynamic content,such as @activity('Set Variable1').value

Upvotes: 1

Related Questions