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 :
- 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 theCopy account to ADL
activity. - Use this variable outside of the
ForEach
loop instead of referencing the activity directly.
- Add a Set Variable activity inside the
- Flatten the Loop Structure: If possible, try to reduce the nesting of
ForEach
activities. You can have a singleForEach
loop and manage the iterations within a single level to allow referencing theCopy account to ADL
activity. - Scope/On-Error Activities: Consider using the built-in failure handling mechanisms like
OnError
orScope
activities. You can wrap yourCopy account to ADL
activity in aScope
activity and handle the error within theScope
.