Azure Data Factory select property “status”: “Succeeded” from previous activity

旧时模样 提交于 2019-12-02 17:56:14

问题


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


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/52612382/azure-data-factory-select-property-status-succeeded-from-previous-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!