You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Web Activity中使用datasets和linkedServices属性及配置问题咨询

Azure Data Factory Web Activity datasets、linkedServices属性使用说明

完整使用示例

首先明确这两个属性的两种使用场景:

场景1:关联ADF已有资源获取权限(最常用场景)

这种场景下datasets、linkedServices是Web Activity配置的顶层属性,和请求方法、请求体平级,作用是让Web Activity继承对应资源的访问权限,无需你在请求里额外拼接密钥。完整JSON配置示例如下:

{
    "name": "SampleWebActivity",
    "type": "WebActivity",
    "typeProperties": {
        "method": "POST",
        "url": "你要调用的接口地址",
        "body": {
            "myMessage": "Sample"
        },
        "datasets": [
            {
                "referenceName": "MyDataset1",
                "type": "DatasetReference"
            }
        ],
        "linkedServices": [
            {
                "referenceName": "MyStorageLinkedService1",
                "type": "LinkedServiceReference"
            }
        ]
    }
}

如果在ADF UI中配置,直接在Web Activity的「设置」标签页下找到datasets、linkedServices的选择框,下拉选择你已经创建好的对应资源即可,无需手动编写JSON。

场景2:将数据集、链接服务定义作为请求内容传递

如果你调用的接口需要接收数据集/链接服务的完整定义信息,才需要把这两个字段放到请求体中,也就是你看到的官方示例的写法,注意需要把占位符替换为实际属性值,示例如下:

{
    "name": "SampleWebActivity",
    "type": "WebActivity",
    "typeProperties": {
        "method": "POST",
        "url": "你要调用的接口地址",
        "body": {
            "myMessage": "Sample",
            "datasets": [{
                "name": "MyDataset1",
                "properties": {
                    "linkedServiceName": {
                        "referenceName": "MyStorageLinkedService1",
                        "type": "LinkedServiceReference"
                    },
                    "type": "AzureBlob",
                    "typeProperties": {
                        "folderPath": "mycontainer/myfolder",
                        "fileName": "myfile.csv"
                    }
                }
            }],
            "linkedServices": [{
                "name": "MyStorageLinkedService1",
                "properties": {
                    "type": "AzureStorage",
                    "typeProperties": {
                        "connectionString": "DefaultEndpointsProtocol=https;AccountName=<你的存储账号名>;AccountKey=<你的存储账号密钥>;EndpointSuffix=core.windows.net"
                    }
                }
            }]
        }
    }
}

配置无法正常运行的原因

你直接套用示例无法运行通常是两个原因导致的:

  • 位置错误:你把原本应该放在顶层的datasets、linkedServices属性写到了body里面,导致Web Activity没有正确关联到ADF中的资源,无法获取对应的访问权限。
  • 占位符未替换:示例中的...是省略的属性占位符,没有实际意义,你需要根据你自己的资源配置补全所有属性值,直接保留...会导致JSON格式非法,或者接口无法识别请求内容。

内容的提问来源于stack exchange,提问作者Yuzuki Ayase

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 19:24:03