Azure数据工厂v2自定义活动.使用Azure Key Vault从linkedService获取连接字符串 [英] Azure data factory v2 custom activities. Get a connection string from a linkedService with Azure Key Vault

查看:54
本文介绍了Azure数据工厂v2自定义活动.使用Azure Key Vault从linkedService获取连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个自定义活动,其中的链接服务位于 ReferenceObjects属性中.我从linkedService.json获取linkedService,但其连接字符串来自KeyVault,而不是字符串值.我怎样才能 从自定义活动中获取connectionString以打开 SqlConnection.

I a custom activity with a linkedService in ReferenceObjects property. I get the linkedService from linkedService.json but its connection string is from a KeyVault not from string value. How can i get the connectionString to open a SqlConnection from the custom activitiy.

示例:

我的管道:

{
    名称":"myPipeline",
    属性":{
        活动":[
            {
                "名称":"myCustomActivity",
                " type":"Custom",
                "policy":{
                    " timeout":"02:00:00",
                    "重试":3,
                    "retryIntervalInSeconds":30,
                    "secureOutput":false,
                    "secureInput":false
                },
                "typeProperties":{
                    "命令":"test.exe",
                    "resourceLinkedService":{
                        " referenceName":"blobLS",
                        类型":"LinkedServiceReference"
                    },
                    "folderPath":"testContainer/Test",
                    "referenceObjects":{
                        "linkedServices":[
                            {
                                " referenceName":"AzureSqlLinkedService",
                                类型":"LinkedServiceReference"
                            }
                        ]
                    }
                },
                "linkedServiceName":{
                    "referenceName":"BatchLS",
                    类型":"LinkedServiceReference"
                }
            }
        ]
    }
}

{
    "name": "myPipeline",
    "properties": {
        "activities": [
            {
                "name": "myCustomActivity",
                "type": "Custom",
                "policy": {
                    "timeout": "02:00:00",
                    "retry": 3,
                    "retryIntervalInSeconds": 30,
                    "secureOutput": false,
                    "secureInput": false
                },
                "typeProperties": {
                    "command": "test.exe",
                    "resourceLinkedService": {
                        "referenceName": "blobLS",
                        "type": "LinkedServiceReference"
                    },
                    "folderPath": "testContainer/Test",
                    "referenceObjects": {
                        "linkedServices": [
                            {
                                "referenceName": "AzureSqlLinkedService",
                                "type": "LinkedServiceReference"
                            }
                        ]
                    }
                },
                "linkedServiceName": {
                    "referenceName": "BatchLS",
                    "type": "LinkedServiceReference"
                }
            }
        ]
    }
}

我的参考linkedService:

My reference linkedService:

{
    "名称":"AzureSqlLinkedService",
    属性":{
        " type":"AzureSqlDatabase",
        "typeProperties":{
            "connectionString":{
                类型":"AzureKeyVaultSecret",
                " store" ;: {
                    "referenceName":"keyVaultLinkedService",
                    类型":"LinkedServiceReference"
                },
                " secretName" ;:" mySecretName"
            }
        }
    }
}

{
    "name": "AzureSqlLinkedService",
    "properties": {
        "type": "AzureSqlDatabase",
        "typeProperties": {
            "connectionString": {
                "type": "AzureKeyVaultSecret",
                "store": {
                    "referenceName": "keyVaultLinkedService",
                    "type": "LinkedServiceReference"
                },
                "secretName": "mySecretName"
            }
        }
    }
}

和我的自定义活动:

推荐答案

请考虑将连接字符串作为秘密存储在AKV中,您需要创建另一个函数/类来获取秘密.你可以下载这个 Azure密钥库c#示例进行查看.这个 线程还为您提供了一些信息.谢谢.

Consider the connection string is stored as the secret in the AKV,  you need to create another function/class to get the secret. You could download this Azure key vault c# sample to take a look. This thread also gives you some information. Thanks.


这篇关于Azure数据工厂v2自定义活动.使用Azure Key Vault从linkedService获取连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆