如何从已执行的管道中获取自定义输出?

How to get custom output from an executed pipeline?

我希望能够从 "Execute Pipeline Activity" 获得自定义输出。在执行调用的管道期间,我使用 "Set Variable" activity 在变量中捕获了一些信息。我希望能够在主管道中使用该值。

我知道主管道可以使用“@activity('InvokedPipeline').output”读取调用管道的名称和 runId,但这些是唯一可用的属性。

我有可调用管道,因为它可以配置为由多个其他管道使用,假设我们可以从中获取输出。它目前由 8 个活动组成;我不想仅仅因为我们无法从调用的管道中获取输出而不得不在多个管道中复制它们。

参考:Execute Pipeline Activity

[
  {
    "name": "MasterPipeline",
    "type": "Microsoft.DataFactory/factories/pipelines"
    "properties": {
        "description": "Uses the results of the invoked pipeline to do some further processing",
        "activities": [
            {
                "name": "ExecuteChildPipeline",
                "description": "Executes the child pipeline to get some value.",
                "type": "ExecutePipeline",
                "dependsOn": [],
                "userProperties": [],
                "typeProperties": {
                    "pipeline": {
                        "referenceName": "InvokedPipeline",
                        "type": "PipelineReference"
                    },
                    "waitOnCompletion": true
                }
            },
            {
                "name": "UseVariableFromInvokedPipeline",
                "description": "Uses the variable returned from the invoked pipeline.",
                "type": "Copy",
                "dependsOn": [
                    {
                        "activity": "ExecuteChildPipeline",
                        "dependencyConditions": [
                            "Succeeded"
                        ]
                    }
                ]
            }
        ],
        "parameters": {},
        "variables": {}
    }
  },
  {
    "name": "InvokedPipeline",
    "type": "Microsoft.DataFactory/factories/pipelines"
    "properties": {
        "description": "The child pipeline that makes some HTTP calls, gets some metadata, and sets a variable.",
        "activities": [
            {
                "name": "SetMyVariable",
                "description": "Sets a variable after some processing from other activities.",
                "type": "SetVariable",
                "dependsOn": [
                    {
                        "activity": "ProcessingActivity",
                        "dependencyConditions": [
                            "Succeeded"
                        ]
                    }
                ],
                "userProperties": [],
                "typeProperties": {
                    "variableName": "MyVariable",
                    "value": {
                        "value": "@activity('ProcessingActivity').output",
                        "type": "Expression"
                    }
                }
            }
        ],
        "parameters": {},
        "variables": {
            "MyVariable": {
                "type": "String"
            }
        }
    }
  }
]

你好希瑟,感谢您的咨询。自定义输出目前不是内置功能。您可以 request/upvote 获取 Azure feedback forum 中的功能。现在,我有两个 work-arounds.

利用调用管道的 运行ID,我们可以查询 REST API(使用 Web Activity)以获取 activity 运行 日志,并且从那里, activity 输出。但是在进行查询之前,有必要进行身份验证。 REST call to get the activities of a pipeline 对于身份验证,我建议使用 Web Activity 获取 oauth2 令牌。 URL 将是 https://login.microsoftonline.com/tenantid/oauth2/token。 Headers "Content-Type": "application/x-www-form-urlencoded" 和 body "grant_type=client_credentials&client_id=xxxx&client_secret=xxxx&resource=https://management.azure.com/"。由于此请求是获取凭据,因此此请求的身份验证设置类型为 'None'。这些凭据对应于您通过 Azure Active Directory > 应用注册创建的应用。不要忘记在数据工厂访问控制 (IAM) 中分配应用程序 RBAC。

另一个 work-around,让 child 管道写入其输出。它可以写入数据库 table,也可以写入 blob(我将数据工厂变量传递给写入 blob 存储的逻辑应用程序),或者您选择的其他内容。由于您计划将 child 管道用于许多不同的 parent 管道,因此我建议向 child 管道传递一个参数,该参数用于识别 parent 的输出.这可能意味着一个 blob 名称,或者将 parent 运行ID 写入 SQL table。这样 parent 管道就知道去哪里寻找输出。