How to Set an Array type variable

Nandan Hegde 36,146 Reputation points MVP Volunteer Moderator
2021-07-12T05:09:45.183+00:00

Hello All,
Below is our ADF flow:

113656-adf-arch.png

I have 3 parallel activities whose error message I need to capture (in case if any) and save it in an Array type variable.

For now I have made activity output as On Completion and with a string type variable concatenated the below value as 1 common string :
@markus.bohland@hotmail.de (activity('1').error?.message,activity('2').error?.message,activity('3').error?.message)

But the requirement is to save each error message as a seperate array element within a variable of type Array.

Any help would be appreciated.

And also is it possible to to append the activity name with the errormsg?

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

2 answers

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,236 Reputation points
    2021-07-12T21:29:18.49+00:00

    Hello again @Nandan Hegde .

    In this case, you should be using, Append Variable not Set Variable. An Append Variable after each activity like below image

    113908-image.png

    Each Append Variable activity can be used to create a "message". Below is code to make a JSON format message for hypothetical activity named "DoThing". First it checks whether the activity succeeded or not. Then it makes message differently for success and fail. For success there is no error message to get. There may be an error message for failure. The .? makes it null-safe. Each Append Variable activity will need its code tweaked to reflect the activity it is reporting on.

    @if(equals(activity('DoThing').Status,'Succeeded'),  
      
    '{"Name":"DoThing" , "status":"Success", "error":"N/A"}',  
      
    concat('{"Name":"DoThing", "Status":"Fail","error":',  
    string(activity('DoThing')?.Error))  
      
    )  
      
    =>  
      
    {"Name":"LookupNull", "status": success or fail , "error": N/A or error message}  
    
    0 comments No comments

  2. Nandan Hegde 36,146 Reputation points MVP Volunteer Moderator
    2021-07-13T04:06:37.713+00:00

    Hey @MartinJaffer-MSFT ,
    Thank you for your inputs :)
    But in my scenario, all the activities are running parallelly and there in order to reduce the number of activities iin pipeline , I tried using 1 set variable activity.
    I was able to achieve it by using Split function on the below appended string :
    @markus.bohland@hotmail.de (activity('1').error?.message,activity('2').error?.message,activity('3').error?.message) to achieve my results.
    But is there a way possible to use only 1 append variable activity for all activity outputs during parallel processing ?


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.