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

Hea*_*sky 10 azure azure-data-factory azure-data-factory-2

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

我知道主管道可以使用“@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"
            }
        }
    }
  }
]
Run Code Online (Sandbox Code Playgroud)

Mar*_*SFT 10

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

利用调用的管道的 runID,我们可以查询 REST API(使用 Web Activity)以获取活动运行日志,并从那里查询活动输出。但是,在进行查询之前,必须进行身份验证。 用于获取管道活动的 REST 调用 对于身份验证,我建议使用 Web 活动来获取 oauth2 令牌。URL 将是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(我将数据工厂变量传递给写入 Blob 存储的逻辑应用程序),或您选择的其他内容。由于您计划将子管道用于许多不同的父管道,我建议向子管道传递一个参数,该参数用于识别父管道的输出。这可能意味着 blob 名称,或将父 runID 写入 SQL 表。这样父管道就知道从哪里获取输出。

  • 您可以在反馈论坛中请求/支持此功能:https://feedback.azure.com/forums/270578-azure-data-factory (3认同)
  • 感谢您提供这两个选项 - 两者都有效!我最终使用第二个选项只是为了避免双重 WebRequest + Authentication malarkey。这是没有必要的,因为来自子管道的数据并不敏感。带有第二个选项的简单查找活动完美运行。但是 +3 允许将来执行管道活动的输出! (2认同)