在Azure数据工厂中查找和预览Web活动:@Item()返回null

时间:2018-05-03 07:55:03

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

如下面链接所述,我首先触发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"
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

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