Bronze Award WinnerBronze Award Winner


Suppose you already have continuous integration set up and built the BizTalk application MSI using BizTalk deployment framework (BTDF), and would like to set up automated continuous deployment, this post shows you how to do it using PowerShell and Octopus Deploy

Applies To

  • BizTalk 2013 R2
  • BTDF 5.6 RC
  • Octopus Deploy v3.0

About the module

This PowerShell module deploys BizTalk applications created using BizTalk Deployment framework (BTDF). The module deploys the MSI through standard BTDF and BizTalk tools as follows: 

  • Takes a backup of the existing version of BizTalk app, if any, MSI and bindings into a specified backup dir.
  • Undeploys the existing version, if any, of BizTalk app.
  • Uninstalls existing version of BizTalk app, if any.
  • Installs the new version of BizTalk MSI created using BTDF.
  • Deploys the newly installed version of BizTalk using BTDF.

For further details, import this module into PowerShell console and use help as follows:

Import-Module "<path where this is located>\publish-BiztalkBtdfApplication.psm1"
get-help publish-BTDFBiztalkApplication -Detailed
#This module also supports  -whatif switch
publish-BTDFBiztalkApplication -whatif

This script was tested with BizTalk 2013 R2 and BTDF Release 5.6 (Release Candidate) . The PowerShell module can be downloaded from here 

Deploying with Octopus Deploy

Import this module as a script module into your octopus library as shown here:

Example - Deploy a BTDF BizTalk application with IIS apppool accounts

#Import-Module .\Publish-BiztalkBtdfApplication.psm1 -Force
##Get MSI from nuget package.
$installDir=$OctopusParameters['Octopus.Action[Get Biztalk Package].Output.Package.InstallationDirectoryPath']
##This assumes you have created a nuget package with the msi and the msi is under content dir when the nuget package is unpacked
$Msi= get-item"$(Join-path $installDir "content\DeploymentFramework.Samples.BasicMasterBindings-4.7.")*.msi"
##Octopus environment variables required for this deployment,
##For non-clustered BizTalk server environments set this to true always
#$IsFirstBiztalkServer = $true
$IsFirstBiztalkServer =$OctopusParameters['Octopus.Tentacle.CurrentDeployment.TargetedRoles'] -contains"Biztalk Primary"
$appPoolIdentity =$OctopusParameters['AppPoolIdentity']
$appPoolPassword =$OctopusParameters['AppPoolPassword']
##initialise variables
$backupDir =join-path  "c:\biztalk apps""Backupdir"
$btdfProductName="Deployment Framework for BizTalk - BasicMasterBindings"
$appInstallDir =join-path  "c:\biztalk apps"$btdfProductName
##If you have more options in your BTDF installwizard.xml, just add them  as name value pairs as shown here.
##PS. The /p: is mandatory :
##Make sure the names or values with spaces are enclosed within double quotes.
##Double quotes in PowerShell strings can be escaped using "" or `"
##In this example, see the value of /p:ENV_Settings is escaped with ""
$deployOptions = @{"/p:VDIR_USERNAME"="$appPoolIdentity";
New-Item $backupDir-ItemType Container-Force
##Publish using the powershell module.
publish-btdfBiztalkApplication  -biztalkMsi$Msi  -installdir $appInstallDir  -biztalkApplicationName $biztalkAppName-btdfProductName $btdfProductName-backupDir $backupDir-importIntoBiztalkMgmtDb  $IsFirstBiztalkServer -deployOptions  $deployOptions
##To see more options available to customise you deployment including custom undeploy options, set msbuild or BTS task paths use get-help
#get-help publish-BTDFBiztalkApplication -Detailed
##To troubleshoot and increase log level use the -Verbose switch
#publish-BTDFBiztalkApplication -verbose

Download the PowerShell module

To obtain the PowerShell module, through Nuget

>Install-Package Publish-BtdfBiztalkApplication

See Also

Another important place to find an extensive amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.