【问题标题】:How to deploy SSIS project with encrypted data?如何使用加密数据部署 SSIS 项目?
【发布时间】:2018-06-25 12:13:46
【问题描述】:

我们有一个 SSIS 项目,其中一个包连接到 REST API。我们使用 HTTP 连接管理器(带有用户名/密码)和脚本组件来打开连接管理器并解析响应。所有包的保护级别都是 EncryptSensitiveWithUserKey。一切都在 Visual Studio 中运行,并且可以使用部署向导部署到 SSIS-DB。在 SSIS-DB 中,我们可以运行包,还可以通过环境更改连接管理器密码/用户名。

但我们无法通过正常的自动化部署来实现这一点:签入到 TFS 并使用 VSTS-buildserver 和 Powershell 脚本。从 SSIS-db 运行包时,我们得到:

无法解密受保护的 XML 节点“DTS:Property”,错误为 0x80070002“系统找不到指定的文件。”。 您可能无权访问此信息。当存在加密错误时会发生此错误。验证正确的密钥是否可用。

我们(相信我们)知道 SSIS 保护级别和加密的工作原理,原因很明显:SSIS 文件使用用户密钥加密,部署向导(由开发人员运行!)使用 SSIS 解密/重新加密-目录键。但是构建服务器没有用户密钥,因此解密步骤无效。 但是,我们认为这应该不是问题,因为密码已被 SSIS 环境替换,但会出现上述错误。

我们已经尝试了所有的保护级别:

  • DontSaveSensitive:包无法在 VS/SSISDB 中运行。
  • EncryptSensitiveWithPassword:PowerShell $folder.DeployProject 命令不支持密码。 Same method as here.

【问题讨论】:

  • 如果您从项目中排除该包,并将其保留为EncryptSensitiveWithUserKey,它是否正确部署到 SSISDB?
  • @billinkc 是的,这个带有 http 连接的包是新添加到工作项目中的。剩余的项目/包仍然可以正常部署和执行。
  • 没有找到可以使用 EncryptSensitiveWithPassword 加密部署的 PowerShell 对象模型。
  • 我可以使用EncryptSensitiveWithPassword,但是哪个部署脚本支持密码参数? (在 VSTS 中调用。)
  • 我采取所有措施只使用DoNotSaveSensitive。您提到 DontSaveSensitive:包可以在 VS/SSISDB 中运行 - 有什么问题?

标签: visual-studio powershell ssis sql-server-data-tools


【解决方案1】:

使用EncryptSensitiveWithUserKey模式,您可以尝试在您的机器上设置构建/发布代理并将服务帐户更改为您的帐户,然后通过此代理进行部署。

【讨论】:

  • 谢谢,但这违背了拥有 cd/ci 管道的想法。 TFS 和 VSTS 是解决方案的要求。我们将它用于三个环境的测试和发布管理。
  • 有了这个要求,用EncryptSensitiveWithUserKey模式是做不到的。您需要调用脚本或工具(我没有找到)使用 EncryptSensitiveWithPassword 模型进行部署。
【解决方案2】:

我现在在使用 Azure DevOps 和针对 SQL Server 2016 的 SSIS DevOps 任务时遇到了同样的问题。

我怀疑使用 Microsoft.SQLServer.Management.IntegrationServices 程序集的行为与 ISDeploymentWizard 可执行文件不同。

我发现这个问题只发生在敏感的package 参数上,而不是project 参数,所以一种解决方案是用project 参数替换敏感的package 参数。

使用目录中的敏感 package 参数运行包时会出现此问题,但在某些情况下,当作为子包执行时,包运行时不会出现问题。

我还发现一些包会报告包执行成功,但查看事件消息时会显示Failed to decrypt protected XML node "DTS:Property" with error 0x80070002

另一种解决方案是execute the ISDeploymentWizard from the command line。这确实需要目标目录文件夹已经存在,因为向导不会创建它。因此,如果目录文件夹不存在,则需要在此之前创建一个步骤。

下面的 PowerShell 脚本应该适用于 SQL Server 2016

### Variables
$targetServer = "localhost"
$targetCatalogFolder = "IsDeploymentWizard"
$sourceFolder = "C:\Users\mhept\source\repos\SsisDeploy\AzureDevOpsSensitiveInChildPackage"

### Ensure Target Catalog Folder Exists
Add-Type -AssemblyName "Microsoft.SQLServer.Management.IntegrationServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL"

$ssisNamespace = "Microsoft.SqlServer.Management.IntegrationServices"

# Create a connection to the server
$sqlConnectionString = "Data Source=" + $targetServer + ";Initial Catalog=master;Integrated Security=SSPI;"
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionString

# Create the Integration Services object
$integrationServices = New-Object $ssisNamespace".IntegrationServices" $sqlConnection

# Get the Integration Services catalog
$catalog = $integrationServices.Catalogs["SSISDB"]
$catalogFolder = $catalog.Folders[$targetCatalogFolder]

if($null -eq $catalogFolder){
    # Create the target folder
    Write-Host "Creating Catalog Folder $targetCatalogFolder"
    $catalogFolder = New-Object $ssisNamespace".CatalogFolder" ($catalog, $targetCatalogFolder, "")
    $catalogFolder.Create()
}

$targetCatalogPath = "/SSISDB/$targetCatalogFolder"

$ispacs = Get-ChildItem -Path $sourceFolder -Filter "*.ispac" -Recurse
$isDeploymentWizard = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\130\SSIS\Setup\DeploymentWizardPath" -Name "(default)"

foreach($ispac in $ispacs) {
    $projectName = $ispac.BaseName
    $sourcePath = $ispac.FullName

    Write-Host "Deploying $projectName ..."
    Start-Process -Wait -FilePath $isDeploymentWizard -ArgumentList "/Silent", "/SourceType:File", "/ModelType:Project", "/SourcePath:$sourcePath", "/DestinationServer:$targetServer", "/DestinationPath:$targetCatalogPath/$projectName"
    Write-Host "Successfully deployed $projectName"
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-29
    • 1970-01-01
    • 2010-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多