Get Error Message of activity failed in switch activity

Swapneel Hosur 106 Reputation points
2022-12-28T15:25:42.89+00:00

Hi @AnnuKumari-MSFT ,

I have been trying to get error message of an activity located inside the switch activity.
The way to get error message is "activity('Insert into Sales')?.Error?.message". The question mark symbol helps us to get error message if the activity is invoked or not invoked. This statement is getting executed successfully in case of if condition (for activities in True as well as False condition)

Now, with Switch activity I have three cases File Empty, File Duplicate and File New. The Switch activity only provides us with "expression" value to determine in which block it would fall. Like I am purposely trying to fail an activity(set duplicate variable) inside File Duplicate case, I won't have any information about the (set duplicate variable)activity unless I am referencing the (set duplicate variable)activity.

Techniques Tried:

1 When I try to mention activities in "Set Variable", I get error stating "The output of the activity can't be referenced since it is either not an ancestor to the current activity or does not exist". In this case ADF doesn't know in which block the failure would occur.
2. I tried inputting the entire concat function inside of a variable to invoke error expression based on expression value of switch activity, but the same is not getting evaulated at run time. Instead, it just shows me the contents of the variable with switch output.
For example: "Switch Activity Failed because an inner activity failed"|concat(....)

There is a property in SSIS called "Delay Validation". I wanted to know if similar implementation is possible with Swicth activity to delay validation of all the activities inside of the switch activity until runtime.

Thanks,
Swapneel

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
Microsoft Security | Active Directory Federation Services
0 comments No comments
{count} votes

Answer accepted by question author
  1. MartinJaffer-MSFT 26,161 Reputation points
    2022-12-28T21:03:57.533+00:00

    Hello @Swapneel Hosur ,
    Thanks for the question and using MS Q&A platform.

    As I understand you are having trouble capturing the error message of an activity inside switch, from an activity outside switch.

    What I recommend is placing a Set Variable inside each of the switch cases to record the error, so you can refer to it outside the switch. Pipeline variables have a single 'scope', meaning no matter where in the pipeline you are, there is only one instance of the variable. Set Variables inside loops point to the same place Set Variables outside loops do.

    I'm not practiced with SSIS, but from what I read, I don't think "Delay Validation" is an option in pipelines, beyond the ?..

    You will get this same "The output of the activity can't be referenced since it is either not an ancestor to the current activity or does not exist" when you try to reference an activity inside ForEach, Until, If activities. I'll explain the ForEach and Until cases.

    In a loop, the same activities are run multiple times. As they are the same, they have the same names. Since they have the same names, you can't specify which instance. Thus referencing inner activities is disallowed.

    Now you might note, "Activities in different cases are required to have different names, and Switch only runs once. Why can't we reference these?"
    I'm not sure, but I suspect it is related to that concept of "Delay Validation". When an activity is NOT run, it is given the status "Skipped". However, I noticed this does not apply to inner activities of the not-run cases. I tested by linking a Fail activity to a Wait activity by a skip-dependency, and ran the other branch.
    Since this activity was not run in the inactive branch, it probably doesn't exist in any way.

    The "ancestor to the current activity" means a direct lineage of activities connected by dependencies is required. This is because dependencies establish the order in which activites are executed. Without this, you might try to get the output of Lookup before it completes, or get a variable before it is set. The ability to reference an activity is linked to the dependency chain. The inner activities do not have a dependency linking to the outer.
    Now you might ask "why can't we make an exception here? The inner activities belong to the switch, and I have dependency on the switch."
    I don't know. I'd have to ask the developers. Maybe it is possible with a feature request. Maybe the back-end architecture precludes it. My hunch is that each inner section is run on a separate compute context.

    Please do let me if you have any queries.

    Thanks
    Martin


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
      • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

0 additional answers

Sort by: Most helpful

Your answer

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