You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从BizTalk Server 2013 R2迁移参与方与协议至2020独立并行环境?

迁移BizTalk Trading Partner参与方与协议至2020服务器的可行方案

针对你并行安装BizTalk 2020、无法使用原生导入导出功能的场景,以下是几个可落地的自动化/半自动化方案:

方案1:基于BizTalk Explorer Object Model (BOM)编写迁移脚本

BizTalk BOM是官方提供的编程接口,可跨版本访问BizTalk配置数据,适合编写PowerShell或C#脚本实现迁移:

  • 步骤1:在旧服务器上读取数据
    编写PowerShell脚本,引用对应版本的Microsoft.BizTalk.ExplorerOM程序集,连接旧BizTalk管理数据库,遍历并导出手动添加的参与方和协议:
    Add-Type -Path "C:\Program Files (x86)\Microsoft BizTalk Server <旧版本号>\Developer Tools\Microsoft.BizTalk.ExplorerOM.dll"
    $btsCatalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
    $btsCatalog.ConnectionString = "Server=<旧DB服务器>;Database=BizTalkMgmtDb;Integrated Security=SSPI"
    
    # 导出所有手动添加的参与方及关联协议
    foreach ($partner in $btsCatalog.Partners) {
        # 跳过系统默认参与方,仅导出手动添加的
        if ($partner.Name -notin @("BizTalkApplication1", "BizTalkServerApplication")) {
            $partnerData = @{
                Name = $partner.Name
                Description = $partner.Description
                Properties = $partner.Properties | Select-Object Name, Value
                Interfaces = $partner.Interfaces | Select-Object Name, Description
                Agreements = @()
            }
            foreach ($agreement in $partner.Agreements) {
                $partnerData.Agreements += @{
                    Name = $agreement.Name
                    LocalInterface = $agreement.LocalInterface.Name
                    PartnerInterface = $agreement.PartnerInterface.Name
                    IsTwoWay = $agreement.IsTwoWay
                }
            }
            $partnerData | ConvertTo-Json | Out-File "Partner_$($partner.Name).json"
        }
    }
    
  • 步骤2:在新服务器上写入数据
    同样使用BOM脚本,读取导出的JSON文件,在新环境中创建对应的参与方和协议:
    Add-Type -Path "C:\Program Files (x86)\Microsoft BizTalk Server 2020\Developer Tools\Microsoft.BizTalk.ExplorerOM.dll"
    $btsCatalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
    $btsCatalog.ConnectionString = "Server=<新DB服务器>;Database=BizTalkMgmtDb;Integrated Security=SSPI"
    
    # 导入参与方
    $partnerFiles = Get-ChildItem "*.json" | Where-Object { $_.Name -like "Partner_*" }
    foreach ($file in $partnerFiles) {
        $partnerData = Get-Content $file | ConvertFrom-Json
        $newPartner = $btsCatalog.Partners.AddNew($partnerData.Name)
        $newPartner.Description = $partnerData.Description
        # 添加参与方属性
        foreach ($prop in $partnerData.Properties) {
            $newPartner.Properties.Add($prop.Name, $prop.Value)
        }
        # 创建参与方接口
        foreach ($interface in $partnerData.Interfaces) {
            $newInterface = $newPartner.Interfaces.AddNew($interface.Name)
            $newInterface.Description = $interface.Description
        }
        $btsCatalog.SaveChanges()
    }
    
    # 导入协议(需确保本地参与方已存在)
    $localPartner = $btsCatalog.Partners["BizTalkApplication1"]
    foreach ($file in $partnerFiles) {
        $partnerData = Get-Content $file | ConvertFrom-Json
        $remotePartner = $btsCatalog.Partners[$partnerData.Name]
        foreach ($agreement in $partnerData.Agreements) {
            $newAgreement = $localPartner.Agreements.AddNew($agreement.Name, $remotePartner)
            $newAgreement.LocalInterface = $localPartner.Interfaces[$agreement.LocalInterface]
            $newAgreement.PartnerInterface = $remotePartner.Interfaces[$agreement.PartnerInterface]
            $newAgreement.IsTwoWay = $agreement.IsTwoWay
            $btsCatalog.SaveChanges()
        }
    }
    
    注意:协议的传输配置、管道绑定等细节需根据新环境的资源补充完善,部分参数可能需要映射新环境的主机、端口ID。

方案2:修正数据库脚本迁移逻辑

如果之前的数据库脚本失败,大概率是未处理关联表或新环境的上下文冲突,以下是核心迁移要点:

  • 核心关联表:
    • dbo.bts_partner:存储参与方基础信息
    • dbo.bts_partner_interface:参与方接口定义
    • dbo.bts_agreement:协议基础信息
    • dbo.bts_agreement_property:协议属性配置
  • 迁移注意事项:
    1. 导出旧数据库中上述表的手动添加数据(过滤系统默认条目)
    2. 替换数据中的MgmtDbName、MgmtDbServer为新环境的数据库信息
    3. 生成新GUID替换旧数据中的PartnerID、AgreementID等字段,避免与新环境资源冲突
    4. 关联新环境的主机、端口ID:若协议绑定了特定资源,需查询新环境对应ID并替换
    5. 导入后执行dbo.bts_UpdateCatalog存储过程刷新BizTalk元数据

方案3:半自动化迁移结合批量配置

如果自动化脚本编写难度大,可采用半自动化方式:

  • 在旧服务器上整理手动添加的参与方和协议的配置文档(含接口、传输、管道参数)
  • 在新服务器上用BizTalk管理控制台批量创建参与方,再利用PowerShell脚本批量配置协议的重复属性(如超时设置、错误处理规则)

内容的提问来源于stack exchange,提问作者cbg23

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 04:55:05