【问题标题】:HTTP request in Azure Data FactoryAzure 数据工厂中的 HTTP 请求
【发布时间】:2020-08-12 18:28:17
【问题描述】:

在 Azure 数据工厂中,我需要使用 HTTP 连接器通过 URL 接入 HTTP 请求。我能够做到这一点以及设置数据集。我遇到问题的地方正在筹备中。这是我需要做的。实现这一目标的最佳方法是什么?

  1. 调用服务基 URL 并检索 TotalPages 返回的标头。
  2. 使用 TotalPages 的值,使用 TotalPages 中的值对带有参数 page(例如 page=1、page=2 等)的 URL 发出后续请求,以形成这些请求。

谢谢。

【问题讨论】:

    标签: http-headers httprequest azure-data-factory


    【解决方案1】:

    好的。所以这里的问题是你不能在数据工厂中嵌套控制结构超过 1 次。解决方案是创建两个或多个管道(又名 Master 和 Child)。

    从主管道中检索您需要执行的任务数量,并将它们传递给 for 循环。在每个活动对的 for 循环中启动一个新的子管道,然后将执行第二个活动。

    如果 Activity 足够简单,您可以完全跳过子管道并直接在第一个 for 循环中执行。

    作为有问题的管道的 Json 表示形式,它应该遵循以下原则:

    {
    "name": "generic_master",
    "properties": {
        "activities": [
            {
                "name": "Web1",
                "type": "WebActivity",
                "dependsOn": [],
                "policy": {
                    "timeout": "7.00:00:00",
                    "retry": 0,
                    "retryIntervalInSeconds": 30,
                    "secureOutput": false,
                    "secureInput": false
                },
                "userProperties": [],
                "typeProperties": {
                    "url": "https://jsonplaceholder.typicode.com/posts/1",
                    "method": "GET"
                }
            },
            {
                "name": "ForEach1",
                "type": "ForEach",
                "dependsOn": [
                    {
                        "activity": "Web1",
                        "dependencyConditions": [
                            "Succeeded"
                        ]
                    }
                ],
                "userProperties": [],
                "typeProperties": {
                    "items": {
                        "value": "@activity('Web1').output",
                        "type": "Expression"
                    },
                    "activities": [
                        {
                            "name": "Execute Pipeline1",
                            "type": "ExecutePipeline",
                            "dependsOn": [],
                            "userProperties": [],
                            "typeProperties": {
                                "pipeline": {
                                    "referenceName": "generic_child",
                                    "type": "PipelineReference"
                                },
                                "waitOnCompletion": true
                            }
                        }
                    ]
                }
            }
        ],
        "annotations": []
    }
    

    }

    {
    "name": "generic_child",
    "properties": {
        "activities": [
            {
                "name": "Web1",
                "type": "WebActivity",
                "dependsOn": [],
                "policy": {
                    "timeout": "7.00:00:00",
                    "retry": 0,
                    "retryIntervalInSeconds": 30,
                    "secureOutput": false,
                    "secureInput": false
                },
                "userProperties": [],
                "typeProperties": {
                    "url": "https://jsonplaceholder.typicode.com/posts/1",
                    "method": "POST"
                }
            }
        ],
        "annotations": []
    }
    

    }

    【讨论】:

      【解决方案2】:

      为了从 HTTP 请求的响应中读取 TotalPages 值,您可以使用“查找”活动来提交 HTTP 请求并将 TotalPages 值存储在具有“设置变量”活动的变量中。 行动: 管道级别:

      • 创建一个名为 TotalPages 的变量 查找活动:
      • 勾选“设置”选项卡上的仅第一行框
      • 作为源数据集,使用为您的 HTTP 请求定义的数据集
      • 选择 GET 方法。 设置变量活动:
      • 在“变量”选项卡上选择 TotalPages 变量
      • 在值框中,单击“添加动态内容”并输入如下内容:@{activity('GetTotalPages').output.firstRow.RegisterSearch['@TotalPages']}

      在我的例子中,查找活动称为 GetTotalPages,我的 HTTP 请求返回 RegisterSearch 数组中的总页数,列名为 @TotalPages

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-21
        • 2017-08-21
        • 2015-02-21
        • 1970-01-01
        • 1970-01-01
        • 2022-11-03
        相关资源
        最近更新 更多