在 Azure 数据工厂中查找和 foreach 到 Web activity:@Item() 返回 null
Lookup and foreach to Web activity in Azure Data factory: @Item() returning null
如下文link所述,我先触发Lookup。它为我提供了电子邮件 ID,然后针对每个电子邮件 ID,我调用了 POST 请求。
Iterating Through azure SQL table in Azure Data Factory
我在For each 的设置项中提到了@pipeline()。parameters.tableList。然后我为每个设置了一个电子邮件通知来检查@pipeline().parameters.leadList 的输出。到目前为止,我理解得很好。
但是当我使用@item() 时它返回 null。
I am confused why @item() giving me null even though
@pipeline().parameters.leadList in child pipeline giving me correct
value?
我采用了这种方法: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"
}
}
}
}
所以我找到了答案。 item() 给了我 null,因为 foreach 参数没有正确解析,因此 item() 中没有任何内容。
如下文link所述,我先触发Lookup。它为我提供了电子邮件 ID,然后针对每个电子邮件 ID,我调用了 POST 请求。
Iterating Through azure SQL table in Azure Data Factory
我在For each 的设置项中提到了@pipeline()。parameters.tableList。然后我为每个设置了一个电子邮件通知来检查@pipeline().parameters.leadList 的输出。到目前为止,我理解得很好。
但是当我使用@item() 时它返回 null。
I am confused why @item() giving me null even though @pipeline().parameters.leadList in child pipeline giving me correct value?
我采用了这种方法: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"
}
}
}
}
所以我找到了答案。 item() 给了我 null,因为 foreach 参数没有正确解析,因此 item() 中没有任何内容。