Introduction

BizTalk Server remains a cornerstone in enterprise integration, but deploying BizTalk applications across environments like Acceptance and Production can be complex and error-prone. In this post, we’ll walk through how to build a robust Azure DevOps pipeline for BizTalk deployments — complete with staged shutdowns, approvals, and PowerShell automation using the BizTalk Deployment Framework (BTDF).


🧱 Architecture Overview

We’ll deploy a BizTalk application to:

  • Acceptance: Two servers, automatic deployment
  • Production: Manual approval required, with staged shutdown:
    • Stop Receive Locations
    • Wait for message processing
    • Stop Send Ports
    • Stop the application
    • Deploy new version
    • Restart everything

🛠️ Azure DevOps Pipeline YAML

Here’s a full YAML pipeline definition:

trigger:
  branches:
    include:
      - main

stages:
- stage: Acceptance
  displayName: 'Deploy to Acceptance'
  jobs:
  - job: DeployAcceptance
    displayName: 'Deploy to Acceptance Servers'
    pool:
      vmImage: 'windows-latest'
    steps:
    - task: PowerShell@2
      displayName: 'Deploy to Server 1'
      inputs:
        targetType: 'inline'
        script: |
          Write-Host "Deploying to Acceptance Server 1"
          # Call BTDF deployment script here
    - task: PowerShell@2
      displayName: 'Deploy to Server 2'
      inputs:
        targetType: 'inline'
        script: |
          Write-Host "Deploying to Acceptance Server 2"
          # Call BTDF deployment script here

- stage: Production
  displayName: 'Deploy to Production'
  dependsOn: Acceptance
  condition: succeeded()
  jobs:
  - deployment: PreProdShutdown
    displayName: 'Shutdown BizTalk Components'
    environment: 'Production'
    strategy:
      runOnce:
        deploy:
          steps:
          - task: PowerShell@2
            displayName: 'Stop Receive Locations'
            inputs:
              targetType: 'inline'
              script: |
                # See PowerShell script below
          - task: PowerShell@2
            displayName: 'Wait for Processing'
            inputs:
              targetType: 'inline'
              script: |
                Start-Sleep -Seconds 300
          - task: PowerShell@2
            displayName: 'Stop Send Ports'
            inputs:
              targetType: 'inline'
              script: |
                # See PowerShell script below
          - task: PowerShell@2
            displayName: 'Stop Application'
            inputs:
              targetType: 'inline'
              script: |
                # See PowerShell script below

  - deployment: DeployProd
    displayName: 'Deploy BizTalk to Production'
    environment: 'Production'
    dependsOn: PreProdShutdown
    strategy:
      runOnce:
        deploy:
          steps:
          - task: PowerShell@2
            displayName: 'Deploy BizTalk Application'
            inputs:
              targetType: 'inline'
              script: |
                # See BTDF deployment script below
          - task: PowerShell@2
            displayName: 'Start Application'
            inputs:
              targetType: 'inline'
              script: |
                # See PowerShell script below

🧩 PowerShell Scripts for BizTalk Automation

🔻 Stop BizTalk Application

$BizTalkMgmtDb = "BizTalkMgmtDb"
$ApplicationName = "MyBizTalkApp"

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.BizTalk.ExplorerOM")
$catalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
$catalog.ConnectionString = "Integrated Security=SSPI;Initial Catalog=$BizTalkMgmtDb;Data Source=localhost"

foreach ($rl in $catalog.ReceiveLocations) {
    if ($rl.Application.Name -eq $ApplicationName -and $rl.Enabled) {
        $rl.Enabled = $false
    }
}

foreach ($sp in $catalog.SendPorts) {
    if ($sp.Application.Name -eq $ApplicationName -and $sp.Status -eq "Started") {
        $sp.Stop()
    }
}

$app = $catalog.Applications[$ApplicationName]
if ($app.Status -ne "Stopped") {
    $app.Stop("StopAll")
}

$catalog.SaveChanges()
Write-Host "Application and components stopped."

🔼 Start BizTalk Application

$BizTalkMgmtDb = "BizTalkMgmtDb"
$ApplicationName = "MyBizTalkApp"

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.BizTalk.ExplorerOM")
$catalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
$catalog.ConnectionString = "Integrated Security=SSPI;Initial Catalog=$BizTalkMgmtDb;Data Source=localhost"

$app = $catalog.Applications[$ApplicationName]
if ($app.Status -ne "Started") {
    $app.Start("StartAll")
}

foreach ($rl in $catalog.ReceiveLocations) {
    if ($rl.Application.Name -eq $ApplicationName -and !$rl.Enabled) {
        $rl.Enabled = $true
    }
}

foreach ($sp in $catalog.SendPorts) {
    if ($sp.Application.Name -eq $ApplicationName -and $sp.Status -ne "Started") {
        $sp.Start()
    }
}

$catalog.SaveChanges()
Write-Host "Application and components started."

📦 Deploy via BTDF

$msbuildPath = "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe"
$deploymentProject = "C:\BizTalk\Deployment\MyBizTalkApp\MyBizTalkApp.Deployment.btdfproj"

& "$msbuildPath" "$deploymentProject" /t:Deploy /p:Configuration=Server
Write-Host "Deployment abgeschlossen."

🧠 Best Practices & Hints

  • Tokenize your bindings in BTDF to support multiple environments
  • Use Azure DevOps Environments to manage approvals and track deployments
  • Add logging and error handling to your PowerShell scripts
  • Use Start-Sleep to allow message queues to drain before stopping send ports
  • Consider BizTalk360 APIs for advanced monitoring and control

✅ Summary

By combining Azure DevOps with PowerShell and BTDF, you can create a fully automated, safe, and repeatable BizTalk deployment pipeline. Acceptance environments get fast feedback, while Production deployments are gated with approvals and staged shutdowns to prevent message loss or downtime.

This approach brings DevOps best practices into the world of BizTalk — and makes your integration landscape more robust, maintainable, and scalable.


Views: 1

🚀 Automating BizTalk Deployments with Azure DevOps and PowerShell

Johannes Rest


.NET Architekt und Entwickler


Beitragsnavigation


Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert