ErrorCode=InvalidTemplate, ErrorMessage=cannot reference action 'Copy account to ADL'. The action 'Copy account to ADL' is nested in a foreach scope of multiple levels.

Siva B 246 Reputation points
2024-09-25T16:30:04.0366667+00:00

Hello,

I have this copy activity inside for each loop and I added pipeline failure alert logic app pipeline to the copy activity on failure.

I'm getting the error message and other details like @activity('Copy account to ADL').Error['message'].

I'm getting this below error now when executing the pipeline:

ErrorCode=InvalidTemplate, ErrorMessage=cannot reference action 'Copy account to ADL'. The action 'Copy account to ADL' is nested in a foreach scope of multiple levels. Referencing repetition actions from outside the scope is supported only when there are no multiple levels of nesting

Can i not use this expression '@activity('Copy account to ADL').Error['message'].' inside the for-each activity. I'm also referencing this outside of the for-each on failure. Is the above error because I used it outside for-each or I can't use copy activity expressions when it's nested?

someone please help

User's image

User's image

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,690 questions
0 comments No comments
{count} votes

Accepted answer
  1. Amira Bedhiafi 24,556 Reputation points
    2024-09-25T20:42:52.3666667+00:00

    ADF does not allow you to reference actions from inside a ForEach loop if those actions are within multiple nested levels of loops. The @activity('Copy account to ADL').Error['message'] expression cannot be used outside of the ForEach activity when the action is nested within it.

    Here are some workarounds :

    1. Use Variables: You can store the error message in a variable within the ForEach loop and then reference that variable outside of the loop. Here's a potential approach:
      • Add a Set Variable activity inside the ForEach loop to capture the error message from the Copy account to ADL activity.
      • Use this variable outside of the ForEach loop instead of referencing the activity directly.
    2. Flatten the Loop Structure: If possible, try to reduce the nesting of ForEach activities. You can have a single ForEach loop and manage the iterations within a single level to allow referencing the Copy account to ADL activity.
    3. Scope/On-Error Activities: Consider using the built-in failure handling mechanisms like OnError or Scope activities. You can wrap your Copy account to ADL activity in a Scope activity and handle the error within the Scope.
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.