【问题标题】:Lookup and foreach to Web activity in Azure Data factory: @Item() returning null在 Azure 数据工厂中查找和 foreach 到 Web 活动:@Item() 返回 null
【发布时间】:2018-10-13 10:55:07
【问题描述】:

正如下面链接中提到的,我首先触发 Lookup。它给了我电子邮件 ID,然后对于每个电子邮件 ID,我正在调用 POST 请求。

Iterating Through azure SQL table in Azure Data Factory

我已经在 For each 的设置中的项目中提到了@pipeline().parameters.tableList。然后我为每个设置了一个电子邮件通知来检查@pipeline().parameters.leadList 的输出。到目前为止,我做得很好。

但是当我使用 @item() 时它返回 null。

我很困惑为什么 @item() 给我 null 即使 子管道中的@pipeline().parameters.leadList 给了我正确的 价值?

我遵循了这种方法:https://docs.microsoft.com/en-us/azure/data-factory/tutorial-bulk-copy-portal

父管道

{
    "name": "LookupToSF",
    "properties": {
        "activities": [
            {
                "name": "LookupToSF",
                "description": "Retrieve the Lead name and email ids from the Lead table of the Salesforce",
                "type": "Lookup",
                "policy": {
                    "timeout": "7.00:00:00",
                    "retry": 0,
                    "retryIntervalInSeconds": 30,
                    "secureOutput": false
                },
                "typeProperties": {
                    "source": {
                        "type": "SalesforceSource",
                        "query": "select name, email from lead where email='abcd@xxxx.com'",
                        "readBehavior": "query"
                    },
                    "dataset": {
                        "referenceName": "SalesforceObjectToAddPersonAskNicely",
                        "type": "DatasetReference"
                    },
                    "firstRowOnly": false
                }
            },
            {
                "name": "TriggerForEachLead",
                "type": "ExecutePipeline",
                "dependsOn": [
                    {
                        "activity": "LookupToSF",
                        "dependencyConditions": [
                            "Succeeded"
                        ]
                    }
                ],
                "typeProperties": {
                    "pipeline": {
                        "referenceName": "SendSurvey",
                        "type": "PipelineReference"
                    },
                    "waitOnCompletion": true,
                    "parameters": {
                        "leadList": {
                            "value": "@activity('LookupToSF').output.value",
                            "type": "Expression"
                        }
                    }
                }
            }
        ]
    }
}

**

子管道

{
    "name": "SendSurvey",
    "properties": {
        "activities": [
            {
                "name": "ForEachLead",
                "type": "ForEach",
                "typeProperties": {
                    "items": {
                        "value": "@pipeline().parameters.leadList",
                        "type": "Expression"
                    },
                    "isSequential": true,
                    "activities": [
                        {
                            "name": "WebActivityToAddPerson",
                            "type": "WebActivity",
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "url": "https://xxxx.asknice.ly/api/v1/person/trigger",
                                "method": "POST",
                                "headers": {
                                    "X-apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                                },
                                "data": {
                                    "email": "@{item().Email}",
                                    "addperson": "true"
                                }
                            }
                        },
                        {
                            "name": "WebActivityForErrorAddingPerson",
                            "type": "WebActivity",
                            "dependsOn": [
                                {
                                    "activity": "WebActivityToAddPerson",
                                    "dependencyConditions": [
                                        "Failed"
                                    ]
                                }
                            ],
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "url": "https://prod-07.australiaeast.logic.azure.com:443/workflows/xxxxxxxxxxxxx",
                                "method": "POST",
                                "headers": {
                                    "Content-Type": "application/json"
                                },
                                "body": {
                                    "Status": "Failure",
                                    "message": "@{activity('WebActivityToAddPerson').output}",
                                    "subject": "Failure in adding"
                                }
                            }
                        },
                        {
                            "name": "WebActivityToSendSurvey",
                            "type": "WebActivity",
                            "dependsOn": [
                                {
                                    "activity": "WebActivityToAddPerson",
                                    "dependencyConditions": [
                                        "Completed"
                                    ]
                                }
                            ],
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "url": "https://xxxxxxxx.asknice.ly/api/v1/person/trigger",
                                "method": "POST",
                                "headers": {
                                    "X-apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                                },
                                "data": "Email=@{item().Email}&triggeremail=true "
                            }
                        },
                        {
                            "name": "WebActivityForErrorSendingSurvey",
                            "type": "WebActivity",
                            "dependsOn": [
                                {
                                    "activity": "WebActivityToSendSurvey",
                                    "dependencyConditions": [
                                        "Failed"
                                    ]
                                }
                            ],
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "url": "https://prod-07.australiaeast.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxx",
                                "method": "POST",
                                "headers": {
                                    "Content-Type": "application/json"
                                },
                                "body": {
                                    "Status": "Failure",
                                    "message": "@{activity('WebActivityToAddPerson').output}",
                                    "subject": "Failure in adding"
                                }
                            }
                        },
                        {
                            "name": "UserAddingNotification",
                            "type": "WebActivity",
                            "dependsOn": [
                                {
                                    "activity": "WebActivityToAddPerson",
                                    "dependencyConditions": [
                                        "Succeeded"
                                    ]
                                }
                            ],
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "url": "https://prod-07.australiaeast.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxx",
                                "method": "POST",
                                "headers": {
                                    "Content-Type": "application/json"
                                },
                                "body": {
                                    "Status": "Success",
                                    "message": "@{activity('WebActivityToAddPerson').output}",
                                    "subject": "User Added/Updated successfully"
                                }
                            }
                        }
                    ]
                }
            },
            {
                "name": "SuccessSurveySentNotification",
                "type": "WebActivity",
                "dependsOn": [
                    {
                        "activity": "ForEachLead",
                        "dependencyConditions": [
                            "Succeeded"
                        ]
                    }
                ],
                "policy": {
                    "timeout": "7.00:00:00",
                    "retry": 0,
                    "retryIntervalInSeconds": 30,
                    "secureOutput": false
                },
                "typeProperties": {
                    "url": "https://prod-07.australiaeast.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxx",
                    "method": "POST",
                    "headers": {
                        "Content-Type": "application/json"
                    },
                    "body": {
                        "Status": "Success",
                        "message": "@{item()}",
                        "subject": "Survey sent successfully"
                    }
                }
            }
        ],
        "parameters": {
            "leadList": {
                "type": "Object"
            }
        }
    }
}

【问题讨论】:

  • 最好添加一些代码而不是链接,这样其他的可以帮助你。
  • 已添加。请使用在线 Jsonviewer。抱歉格式化。

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


【解决方案1】:

所以我找到了答案。 item() 给了我 null 因为 foreach 参数没有正确解析,因此 item() 中没有任何内容。

【讨论】:

    猜你喜欢
    • 2021-12-17
    • 2022-11-11
    • 1970-01-01
    • 2021-06-10
    • 1970-01-01
    • 2021-12-25
    • 2021-09-08
    • 1970-01-01
    • 2018-11-22
    相关资源
    最近更新 更多