我正在处理SSIS Package。我在现有的SSIS Package中添加了一个数据流任务。在添加新任务后,我重新构建了Package,它成功地完成了,没有出现任何错误。 我需要将其部署到开发服务器吗?
我正在处理SSIS Package。我在现有的SSIS Package中添加了一个数据流任务。在添加新任务后,我重新构建了Package,它成功地完成了,没有出现任何错误。 我需要将其部署到开发服务器吗?
在Visual Studio中的2012 SSIS项目部署模型中,包含了项目参数、项目级别连接管理器、包以及其他你添加到项目中的任何内容。
在下面的图片中,你可以看到我有一个名为Lifecycle的解决方案。该解决方案有一个名为Lifecycle的项目。Lifecycle项目有一个项目级别连接管理器ERIADOR
定义和两个SSIS包:Package00.dtsx和Package01.dtsx。
bin\Development
子文件夹中找到。
Lifecycle.ispac是一个包含以下内容的zip文件。
SSDT实际上只是构建对某些原因存在32位和64位版本的ISDeploymentWizard.exe的调用。
.ispac扩展名与ISDeploymentWizard相关联,双击即可运行。与使用SSDT界面相比,第一个屏幕是新的,但之后,部署将是相同的一组点击操作。
他们在2012年发布中做得正确的是,可以以自动化方式部署清单文件。我有一个workaround,但它应该成为标准“事情”。
因此,请仔细查看来自SSDT或GUI部署的“Review”选项卡。那不是美丽吗?
C:\Program Files\Microsoft SQL Server\110\DTS\Binn\ISDeploymentWizard.exe
/Silent
/SourcePath:"C:\Dropbox\presentations\SSISDB Lifecycle\Lifecycle\Lifecycle\bin\Development\Lifecycle.ispac"
/DestinationServer:"localhost\dev2012"
/DestinationPath:"/SSISDB/Folder/Lifecycle"
您可以通过SQL Server Management Studio(SSMS)或命令行sqlcmd.exe将ispac部署到SQL Server。虽然SQLCMD并非严格要求,但它简化了脚本。
您必须使用Windows帐户执行此操作,否则将收到以下错误消息。
不能使用使用SQL Server身份验证的帐户启动操作。请使用使用Windows身份验证的帐户启动操作。
此外,您需要能够执行批量操作(以序列化.ispac),并具有ssis_admin / sa权限以访问SSISDB数据库。
在这里,我们使用带有BULK选项的OPENROWSET将ispac读入varbinary变量中。如果不存在,我们通过catalog.create_folder创建一个文件夹,然后使用catalog.deploy_project实际部署项目。完成后,我喜欢检查操作消息表以验证是否如预期运行。USE SSISDB
GO
-- You must be in SQLCMD mode
-- setvar isPacPath "C:\Dropbox\presentations\SSISDB Lifecycle\Lifecycle\Lifecycle\bin\Development\Lifecycle.ispac"
:setvar isPacPath "<isPacFilePath, nvarchar(4000), C:\Dropbox\presentations\SSISDB Lifecycle\Lifecycle\Lifecycle\bin\Development\Lifecycle.ispac>"
DECLARE
@folder_name nvarchar(128) = 'TSQLDeploy'
, @folder_id bigint = NULL
, @project_name nvarchar(128) = 'TSQLDeploy'
, @project_stream varbinary(max)
, @operation_id bigint = NULL;
-- Read the zip (ispac) data in from the source file
SELECT
@project_stream = T.stream
FROM
(
SELECT
*
FROM
OPENROWSET(BULK N'$(isPacPath)', SINGLE_BLOB ) AS B
) AS T (stream);
-- Test for catalog existences
IF NOT EXISTS
(
SELECT
CF.name
FROM
catalog.folders AS CF
WHERE
CF.name = @folder_name
)
BEGIN
-- Create the folder for our project
EXECUTE [catalog].[create_folder]
@folder_name
, @folder_id OUTPUT;
END
-- Actually deploy the project
EXECUTE [catalog].[deploy_project]
@folder_name
, @project_name
, @project_stream
, @operation_id OUTPUT;
-- Check to see if something went awry
SELECT
OM.*
FROM
catalog.operation_messages AS OM
WHERE
OM.operation_message_id = @operation_id;
就像您的托管对象模型提供了一个.NET接口来部署包。这是一种PowerShell方法,用于部署ispac并创建文件夹,因为这是ISDeploymentWizard不支持的选项。
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.IntegrationServices") | Out-Null
#this allows the debug messages to be shown
$DebugPreference = "Continue"
# Retrieves a 2012 Integration Services CatalogFolder object
# Creates one if not found
Function Get-CatalogFolder
{
param
(
[string] $folderName
, [string] $folderDescription
, [string] $serverName = "localhost\dev2012"
)
$connectionString = [String]::Format("Data Source={0};Initial Catalog=msdb;Integrated Security=SSPI;", $serverName)
$connection = New-Object System.Data.SqlClient.SqlConnection($connectionString)
$integrationServices = New-Object Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices($connection)
# The one, the only SSISDB catalog
$catalog = $integrationServices.Catalogs["SSISDB"]
$catalogFolder = $catalog.Folders[$folderName]
if (-not $catalogFolder)
{
Write-Debug([System.string]::Format("Creating folder {0}", $folderName))
$catalogFolder = New-Object Microsoft.SqlServer.Management.IntegrationServices.CatalogFolder($catalog, $folderName, $folderDescription)
$catalogFolder.Create()
}
return $catalogFolder
}
# Deploy an ispac file into the SSISDB catalog
Function Deploy-Project
{
param
(
[string] $projectPath
, [string] $projectName
, $catalogFolder
)
# test to ensure file exists
if (-not $projectPath -or -not (Test-Path $projectPath))
{
Write-Debug("File not found $projectPath")
return
}
Write-Debug($catalogFolder.Name)
Write-Debug("Deploying $projectPath")
# read the data into a byte array
[byte[]] $projectStream = [System.IO.File]::ReadAllBytes($projectPath)
# $ProjectName MUST match the value in the .ispac file
# else you will see
# Failed to deploy the project. Fix the problems and try again later.:The specified project name, test, does not match the project name in the deployment file.
$projectName = "Lifecycle"
$project = $catalogFolder.DeployProject($projectName, $projectStream)
}
$isPac = "C:\Dropbox\presentations\SSISDB Lifecycle\Lifecycle\Lifecycle\bin\Development\Lifecycle.ispac"
$folderName = "Folder"
$folderName = "SSIS2012"
$folderDescription = "I am a description"
$serverName = "localhost\dev2012"
$catalogFolder = Get-CatalogFolder $folderName $folderDescription $serverName
Deploy-Project $isPac $projectName $catalogFolder
以下是关于在 SSIS 2016 中部署单个包的更新(希望这对您有用)。
随着 SQL Server 2016 和 SSDT 2015 的发布,单个包部署的问题现在已成为过去。有了新的“部署包”选项(VS 2015),可以在项目部署模型中部署单个包。
通过此新功能,您还可以通过点击并按住控制键(Ctrl)选择要部署的包来部署多个包。
除 Visual Studio 2015 中的“部署包”选项外,您还可以使用其他一些可能性来部署包,例如启动 ISDeploymentWizard 应用程序或进行 命令行部署(此选项在 SSIS 构建和部署自动化或作为持续集成流程的一部分进行管理时是必要的)。 您可以通过导航到本文了解更多信息:http://www.sqlshack.com/single-package-deployment-in-sql-server-integration-services-2016/