Azure Data Factory - Dynamic Account information - Parameterization of Connection

て烟熏妆下的殇ゞ 提交于 2019-12-24 20:27:12

问题


The documentation demonstrates how to create a parameter for a connected service but not how to actual pass in that parameter from a dataset or activity. Basically the connection string is coming from a lookup foreach loop and I want to connect to a storage table.

The connection looks like this. The test works when passing in a correct parameter:

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

The dataset is the following, I'm struggling to determine how to set the connectionString parameter for the connection. The dataset has two parameters, the connectionstring from the db and the tablename that it needs to connect to:

{
    "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"
            }
        }
    }
}

How do I set the connection string on the connection?


回答1:


  1. First, you can't make the whole connection string as an expression. You need provide accountName and accountKey sperately. Refer this post about how to do it. How to provide connection string dynamically for azure table storage/blob storage in Azure data factory Linked service
  2. Then, if you are using ADF UI, it will guide you how to provide value for linked service. For example, if you have two dataset parameters, you could specify it as following.
  3. If you want to see json code, you could click the code icon on the top left corner.
  4. I am using azure blob as an example, but the azure table is almost the same. Hope it could help.


来源:https://stackoverflow.com/questions/56995437/azure-data-factory-dynamic-account-information-parameterization-of-connectio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!