Azure 数据工厂 - 动态帐户信息 - 连接参数化

Azure Data Factory - Dynamic Account information - Parameterization of Connection

文档演示了如何为连接的服务创建参数,但没有演示如何从数据集或 activity 实际传递该参数。基本上连接字符串来自查找 foreach 循环,我想连接到存储 table.

连接看起来像这样。传入正确参数时测试有效:

{
    "name": "StatsStorage",
    "properties": {
        "type": "AzureTableStorage",
        "parameters": {
            "connectionString": {
                "type": "String"
            }
        },
        "annotations": [],
        "typeProperties": {
            "connectionString": "@{linkedService().connectionString}"
        }
    }
}

数据集如下,我正在努力确定如何为连接设置 connectionString 参数。数据集有两个参数,来自数据库的连接字符串和它需要连接到的table名称:

{
    "name": "TestTable",
    "properties": {
        "linkedServiceName": {
            "referenceName": "StatsStorage",
            "type": "LinkedServiceReference"
        },
        "parameters": {
            "ConnectionString": {
                "type": "string"
            },
            "TableName": {
                "type": "string"
            }
        },
        "annotations": [],
        "type": "AzureTable",
        "schema": [],
        "typeProperties": {
            "tableName": {
                "value": "@dataset().TableName",
                "type": "Expression"
            }
        }
    }
}

如何在连接上设置连接字符串?

  1. 首先,您不能将整个连接字符串作为一个表达式。您需要分别提供 accountName 和 accountKey。请参阅此 post 了解如何操作。 How to provide connection string dynamically for azure table storage/blob storage in Azure data factory Linked service
  2. 那么,如果您正在使用ADF UI,它将指导您如何为链接服务提供价值。例如,如果您有两个数据集参数,您可以按如下方式指定它。
  3. 如果您想查看 json 代码,可以单击左上角的代码图标。
  4. 我以 azure blob 为例,但是 azure table 几乎是一样的。 希望它能有所帮助。