你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

在 Azure 数据工厂中加密本地数据存储的凭据

适用于: Azure 数据工厂 Azure Synapse Analytics

提示

试用 Microsoft Fabric 中的数据工厂,这是一种适用于企业的一站式分析解决方案。 Microsoft Fabric 涵盖从数据移动到数据科学、实时分析、商业智能和报告的所有内容。 了解如何免费开始新的试用

可以在装有自承载集成运行时的计算机上加密和存储任何本地数据存储(包含敏感信息的链接服务)的凭据。

注意

建议使用 Azure Az PowerShell 模块与 Azure 交互。 请参阅安装 Azure PowerShell 以开始使用。 若要了解如何迁移到 Az PowerShell 模块,请参阅 将 Azure PowerShell 从 AzureRM 迁移到 Az

将包含凭据的 JSON 定义文件传递到
New-AzDataFactoryV2LinkedServiceEncryptedCredential cmdlet,以生成包含已加密凭据的输出 JSON 定义文件。 然后,使用更新的 JSON 定义来创建链接服务。

使用加密凭据创建链接服务

此示例说明如何使用加密凭据创建与本地 SQL Server 数据源的链接服务。

创建初始链接服务 JSON 文件说明

创建包含以下内容的名为“SqlServerLinkedService.json”的 JSON 文件:

<servername><databasename><username><password> 替换为 SQL Server 的值,然后保存文件。 另外,将 <integration runtime name> 替换为集成运行时的名称。

{
    "properties": {
        "type": "SqlServer",
        "typeProperties": {
            "connectionString": "Server=<servername>;Database=<databasename>;User ID=<username>;Password=<password>;Timeout=60"
        },
        "connectVia": {
            "type": "integrationRuntimeReference",
            "referenceName": "<integration runtime name>"
        },
        "name": "SqlServerLinkedService"
    }
}

加密凭据

若要在本地自承载集成运行时中加密 JSON 有效负载中的敏感数据,请运行 New-AzDataFactoryV2LinkedServiceEncryptedCredential 并传递 JSON 有效负载。 此 cmdlet 可确保使用 DPAPI 加密凭据,并将其存储在自承载集成运行时节点本地。 包含对凭据的加密引用的输出有效负载可以重定向到另一个 JSON 文件(在本例中为“encryptedLinkedService.json”)。

请确保满足以下先决条件:

  • 在自承载集成运行时上启用远程访问选项。
  • 使用 Powershell 7.0 或更高版本执行 cmdlet。
New-AzDataFactoryV2LinkedServiceEncryptedCredential -DataFactoryName $dataFactoryName -ResourceGroupName $ResourceGroupName -IntegrationRuntimeName 'test-selfhost-ir' -DefinitionFile ".\SQLServerLinkedService.json" > encryptedSQLServerLinkedService.json

使用包含已加密凭据的 JSON

现在,使用前一命令输出的包含已加密凭据的 JSON 文件来设置 SqlServerLinkedService

Set-AzDataFactoryV2LinkedService -DataFactoryName $dataFactoryName -ResourceGroupName $ResourceGroupName -Name "EncryptedSqlServerLinkedService" -DefinitionFile ".\encryptedSqlServerLinkedService.json"

有关数据移动安全注意事项的信息,请参阅数据移动安全注意事项