0
votes

with Data Factory V2 I'm trying to implement a stream of data copy from one Azure SQL database to another.

I would like to perform a conditional activity If Condition depends on the success of the previous activities execute by the pipeline, but in the expression to be included in the activity of If Condition I can not select the output property "status": "Succeeded".

Before the activity of If Condition I have two data copy activities.

I added an If Condition activity to my flow because the tasks to perform after copying the data depend on the success of all the copy activities.

i.e.

if all copy activities are performed correctly then the true condition will be executed. If only one copy activity is successful and the other fails then the false condition is executed

The output of each copy activities is as follows:

Output
{
    "dataRead": 213156,
    "dataWritten": 213156,
    "rowsRead": 3554,
    "rowsCopied": 3554,
    "copyDuration": 4,
    "throughput": 52.04,
    "errors": [],
    "effectiveIntegrationRuntime": "DefaultIntegrationRuntime (West Europe)",
    "usedDataIntegrationUnits": 4,
    "usedParallelCopies": 1,
    "executionDetails": [
        {
            "source": {
                "type": "AzureSqlDatabase"
            },
            "sink": {
                "type": "AzureSqlDatabase"
            },
            "status": "Succeeded",
            "start": "2018-10-02T13:42:37.7396813Z",
            "duration": 4,
            "usedDataIntegrationUnits": 4,
            "usedParallelCopies": 1,
            "detailedDurations": {
                "queuingDuration": 3,
                "preCopyScriptDuration": 0,
                "timeToFirstByte": 0,
                "transferDuration": 1
            }
        }
    ]
}

And I structured my expression for If Condition activity like that:

@and(equals(activity('Copy_Activity1').output.executionDetails[3],'Succeeded'), equals(activity('Copy_Activity2').output.executionDetails[3],'Succeeded'))

But he gives me the following error:

"error": {
    "code": "InvalidTemplate",
    "message": "Unable to process template language expressions in action 'If Condition1' inputs at line '1' and column '1294': 'The template language expression 'and(equals(activity('Copy_Item_Budget_Name').output.executionDetails[3],'Succeeded'), equals(activity('Copy_Item_Budget_Entry').output.executionDetails[3],'Succeeded'))' cannot be evaluated because array index '3' is outside bounds (0, 0) of array. Please see https://aka.ms/logicexpressions for usage details.'."
}

But even with the guide I can not solve the problem.

Does anyone know how to solve the problem? Thank you

3

3 Answers

3
votes

From the output data, executionDetails is an array with only one item which contains an object. So the expression should be: activity('Copy_Activity1').output.executionDetails[0].status.

0
votes

If your requirement is to run some activities after ALL the copy activities completed successfully, Johns-305's answer is actually correct.

Here's the example with more detailed information. Copy activities are activity 1 and activity 2, other activities to run after them are activity 3 and activity 4, no dependency between activity 3 and activity 4. The activities should be linked as below picture. Please be aware that, the activity 3 and activity 4 will not be run twice, they will be run only after both of activity 1 and activity 2 are succeeded. Activity graph of the example

-2
votes

For clarity, that's not how flow control works in ADF.

You don't need to query the result of the previous shape, instead, you change the Activity Connector to branch based on the outcome.

After connecting two Activities, right click on the line/arrow. Then you can choose to run the next Activity on any of Success, Failure, Completion or Skip.

You can link any number of Activities before and after it.