Azure数据工厂活动副本从foreach活动获取多个表名

时间:2018-09-27 09:54:42

标签: azure foreach azure-data-factory azure-data-factory-2

使用Data Factory V2,我正在尝试实现从一个Azure SQL数据库到另一个Azure SQL数据库的数据复制流。 我必须将多个表合并到一个目标表中。

为此,我创建了一个查找活动,该活动创建了要复制的三个表的名称。输出JSON文件将传递到foreach活动,该活动应将每个表的数据复制到目标表中,但是管道执行不成功。

我在下面报告我的管道代码:

{
"name": "FLD_Item_base",
"properties": {
    "activities": [
        {
            "name": "myLookup",
            "type": "Lookup",
            "dependsOn": [
                {
                    "activity": "myStoredProcedure",
                    "dependencyConditions": [
                        "Succeeded"
                    ]
                }
            ],
            "policy": {
                "timeout": "7.00:00:00",
                "retry": 0,
                "retryIntervalInSeconds": 30,
                "secureOutput": false,
                "secureInput": false
            },
            "typeProperties": {
                "source": {
                    "type": "SqlSource",
                    "sqlReaderQuery": "SELECT tsy_company_desc, tsy_tabella_desc, tsy_company_id, \ncase when tsy_company_desc = 'all' \nthen '['+ tsy_tabella_desc + ']' else '['+tsy_company_desc + '$' + tsy_tabella_desc + ']'  end as nome_tabella_completo \nfrom dbo.TSY_FLUSSI_LOAD_DWH \nwhere tsy_flusso_desc = 'item_base' \nand tsy_tabella_desc='Item' \n"
                },
                "dataset": {
                    "referenceName": "TLD_Item",
                    "type": "DatasetReference"
                },
                "firstRowOnly": false
            }
        },
        {
            "name": "myStoredProcedure",
            "type": "SqlServerStoredProcedure",
            "policy": {
                "timeout": "7.00:00:00",
                "retry": 0,
                "retryIntervalInSeconds": 30,
                "secureOutput": false,
                "secureInput": false
            },
            "typeProperties": {
                "storedProcedureName": "[dbo].[myStoredProcedure]"
            },
            "linkedServiceName": {
                "referenceName": "Sink",
                "type": "LinkedServiceReference"
            }
        },
        {
            "name": "IterateSQLTables",
            "type": "ForEach",
            "dependsOn": [
                {
                    "activity": "myLookup",
                    "dependencyConditions": [
                        "Succeeded"
                    ]
                }
            ],
            "typeProperties": {
                "items": {
                    "value": "@activity('myLookup').output",
                    "type": "Expression"
                },
                "activities": [
                    {
                        "name": "FullCopyActivity",
                        "type": "Copy",
                        "policy": {
                            "timeout": "7.00:00:00",
                            "retry": 0,
                            "retryIntervalInSeconds": 30,
                            "secureOutput": false,
                            "secureInput": false
                        },
                        "typeProperties": {
                            "source": {
                                "type": "SqlSource",
                                "sqlReaderQuery": {
                                    "value": "SELECT * FROM @{item().value.name_tab}",
                                    "type": "Expression"
                                }
                            },
                            "sink": {
                                "type": "SqlSink",
                                "writeBatchSize": 10000
                            },
                            "enableStaging": false,
                            "dataIntegrationUnits": 0
                        },
                        "inputs": [
                            {
                                "referenceName": "Source",
                                "type": "DatasetReference"
                            }
                        ],
                        "outputs": [
                            {
                                "referenceName": "TLD_Item",
                                "type": "DatasetReference"
                            }
                        ]
                    }
                ]
            }
        }

管道执行返回以下错误:

{
"errorCode": "400",
"message": "Activity failed because an inner activity failed",
"failureType": "UserError",
"target": "IterateSQLTables"
}

有人知道如何解决问题吗?谢谢

1 个答案:

答案 0 :(得分:3)

请在活动@activity('myLookup').output.value的{​​{1}}中尝试用@activity('myLookup').output代替items

您可以找到用于查找活动here的文档