lucuma
lucuma

Reputation: 18339

Azure Data Factory - Dynamic Account information - Parameterization of Connection

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?

Upvotes: 0

Views: 262

Answers (1)

Fang Liu
Fang Liu

Reputation: 2363

  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. enter image description here
  3. If you want to see json code, you could click the code icon on the top left corner. enter image description here
  4. I am using azure blob as an example, but the azure table is almost the same. Hope it could help.

Upvotes: 1

Related Questions