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

希瑟·萨瓦茨基(Heather Sawatsky)

我希望能够从“执行管道活动”获得自定义输出。在执行调用的管道期间,我使用“设置变量”活动在变量中捕获了一些信息。我希望能够在主管道中使用该值。

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

我有可调用管道,因为假设我们可以从中获取输出,那么它可以配置为供其他多个管道使用。它目前包括8个活动;我讨厌不得不在多个管道中复制它们,只是因为我们无法从调用的管道中获得输出。

参考:执行管道活动

[
  {
    "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"
            }
        }
    }
  }
]
马丁·雅弗

您好希瑟,谢谢您的询问。自定义输出目前不是内置功能。您可以在Azure反馈论坛中请求/支持该功能目前,我确实有两种解决方法。

利用调用的管道的runID,我们可以查询REST API(使用Web Activity)以获取活动运行日志,然后从那里查询活动输出。但是,在进行查询之前,有必要进行身份验证。REST调用以获取管道的活动对于身份验证,我建议使用Web Activity来获取oauth2令牌。该网址为https://login.microsoftonline.com/tenantid/oauth2/token标头"Content-Type": "application/x-www-form-urlencoded"和正文"grant_type=client_credentials&client_id=xxxx&client_secret=xxxx&resource=https://management.azure.com/"由于此请求是为了获取凭据,因此此请求的“身份验证”设置为“无”。这些凭据对应于您通过Azure Active Directory>应用程序注册创建的应用程序。不要忘记在数据工厂访问控制(IAM)中分配应用RBAC。

另一个解决方法是让子管道写入其输出。它可以写入数据库表,也可以写入blob(我将Data Factory变量传递给了写入blob存储的Logic App),也可以写入您选择的其他东西。由于您打算将子管道用于许多不同的父管道,因此我建议向子管道传递一个参数,该参数用于标识到父管道的输出。这可能意味着一个blob名称,或将父运行ID写入SQL表。这样,父管道可以知道在哪里获取输出。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章