首页 > 解决方案 > Azure 数据工厂:使用 Azure Key Vault 参考获取链接服务中的用户名,这可能吗?

问题描述

我知道您可以在 ADF 中创建一个 Azure Key Vault 链接服务,然后可以在其他链接服务中使用它来获取密码密钥/连接字符串密钥。 ADF 门户链接服务设置 这是从 Keyvault 密钥中检索 FILE SYSTEM 链接服务的密码时 JSON 的样子(请参阅 ADF UI 片段的屏幕截图):

{
"name": "FILESERVER_blah",
"properties": {
    "annotations": [],
    "type": "FileServer",
    "typeProperties": {
        "host": "\\\\ServerName\\ShareName",
        "userId": "ThisIsMyUserName@blah.com",
        "password": {
            "type": "AzureKeyVaultSecret",
            "store": {
                "referenceName": "KEYVAULT_maddisandbox",
                "type": "LinkedServiceReference"
            },
            "secretName": "MySecretName"
        }
    },
    "connectVia": {
        "referenceName": "shir-madie-sandbox",
        "type": "IntegrationRuntimeReference"
    }
}}

有了这个逻辑,我想我可以在 KeyVault 中创建一个 UserName 机密并以相同的方式引用它。所以我将链接服务 Json 更新为以下内容:

{
"name": "FILESERVER_akv_dynamic",
"properties": {
    "type": "FileServer",
    "annotations": [],
    "parameters": {
        "UserSecretName": {
            "type": "string",
            "defaultValue": ""
        },
        "PasswordSecretName": {
            "type": "string",
            "defaultValue": ""
        },
        "Host": {
            "type": "string",
            "defaultValue": ""
        }
    },
    "typeProperties": {
        "host": "@linkedService().Host",
        "userId": {
            "type": "AzureKeyVaultSecret",
            "store": {
                "referenceName": "KEYVAULT_maddisandbox",
                "type": "LinkedServiceReference"
            },
            "secretName": "@linkedService().UserSecretName"
        },
        "password": {
            "type": "AzureKeyVaultSecret",
            "store": {
                "referenceName": "KEYVAULT_maddisandbox",
                "type": "LinkedServiceReference"
            },
            "secretName": "@linkedService().PasswordSecretName"
        }
    },
    "connectVia": {
        "referenceName": "shir-madie-sandbox",
        "type": "IntegrationRuntimeReference"
    }
}}

当我这样做并尝试运行测试连接时,它会返回此错误:

Failed to convert the value in 'userid' property to 'System.String' type. Please make sure the payload structure and value are correct.

我知道我可以使用 KeyVault REST API 来获取 Secret 值并将其传递给我的活动/数据集/链接服务,但我更愿意使用本机功能并通过直接在链接服务 Json 中引用来节省一步,特别是因为我在我的工厂设置了 KeyVault 链接服务。

如果可能的话,有人可以解释如何使这项工作吗?如果不可能,为什么不可能?密码机密的处理方式与我尝试检索的用户名机密有何不同?

谢谢

标签: azureazure-data-factoryazure-keyvault

解决方案


目前设计上只有秘密或连接字符串(对于在 SQL Server、Blob 存储等链接服务中使用连接字符串的连接器,您可以选择仅在 AKV 中存储秘密字段,例如密码,或存储AKV 中的整个连接字符串。您可以在 UI 上找到这两个选项。)允许通过 ADF 链接服务从 AKV 检索。

因此,无法通过 ADF 链接服务从 AKV 检索用户名。这是一个设计限制。

相关 MS 文档:在 Azure Key Vault 中存储凭据

但如果您对此有任何具体反馈,请随时在 ADF 用户语音论坛中分享您的建议/想法:https ://feedback.azure.com/forums/270578-azure-data-factory 。


推荐阅读