Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 如何使用加密数据部署SSIS项目?_Visual Studio_Powershell_Ssis_Sql Server Data Tools - Fatal编程技术网

Visual studio 如何使用加密数据部署SSIS项目?

Visual studio 如何使用加密数据部署SSIS项目?,visual-studio,powershell,ssis,sql-server-data-tools,Visual Studio,Powershell,Ssis,Sql Server Data Tools,我们有一个SSIS项目,其中一个包连接到RESTAPI。我们使用HTTP连接管理器(带有用户名/密码)和脚本组件打开连接管理器并解析响应。所有包的保护级别都是EncryptSensitiveWithUserKey。一切都在Visual Studio中工作,可以使用部署向导将其部署到SSIS-DB。在SSIS-DB中,我们可以运行包,还可以通过环境更改连接管理器密码/用户名 但我们无法通过正常的自动部署实现这一点:签入TFS并将VSTS buildserver与Powershell脚本一起使用。从

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

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

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

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

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

  • DontSaveSensitive:包无法在VS/SSIDB中运行
  • EncryptSensiveWithPassword:PowerShell$folder.DeployProject命令中不支持密码
使用EncryptSensitiveWithUserKey模式,您可以尝试在您的计算机上设置build/release代理,并将服务帐户更改为您的帐户,然后通过此代理进行部署。

我现在在Azure DevOps和SSIS DevOps任务中遇到同样的问题,目标是SQL Server 2016

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

我发现此问题仅出现在敏感的
参数上,而不是
项目
参数上,因此一种解决方案是将敏感的
参数替换为
项目
参数

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

我还发现,一些包会报告成功执行包,但查看事件消息时,会出现
未能解密受保护的XML节点“DTS:Property”,错误为0x80070002

另一种解决办法是。这确实需要目标目录文件夹已经存在,因为向导不会创建它。因此,如果目录文件夹不存在,则需要在此之前执行一个步骤来创建目录文件夹

下面的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"
}

如果将包从项目中排除,并将其保留为
EncryptSensitiveWithUserKey
,它是否正确部署到SSISDB?@billinkc是此具有http连接的包是新添加到工作项目的。剩余的项目/包仍可以部署和执行。未找到可以使用EncryptSensiveWithPassword encrypted部署的PowerShell对象模型。我可以使用
EncryptSensiveWithPassword
,但哪个部署脚本支持password参数?(在VSTS中调用。)我采取所有步骤仅使用
DoNotSaveSensitive
。您提到DontSaveSensitive:包可以在VS/SSIDB中运行-有什么问题吗?谢谢,但这与使用cd/ci管道的想法背道而驰。TFS和VST是解决方案的一项要求。我们使用它对三种环境进行测试和发布管理。根据这一要求,您不能使用EncryptSensitiveWithUserKey模式。您需要调用脚本或工具(我找不到)来使用EncryptSensitiveWithPassword模型进行部署。