On our current BizTalk 2009 project we have 10 applications which have to be deployed to 10 servers and more applications and servers are on their way. Somehow we had to manage this in an easy way and I think we found a pretty nice and easy way to do this using some XML replacement and PowerShell.
We had the following requirements:
- Easy to maintain, even with multiple environments.
- Environment-specific settings should be contained within a single file per BizTalk-application without any need to edit binding-files.
- Deployment should be done using a single package that can be reused on multiple environments.
- As few third party utilities as possible should be used to minimize complexity
I have previously looked at BizTalk Deployment Framework, but found this way to complex and with too many 3rd party tools. And I really do not like messing with Visual Studios default templates so this was considered a no go.
Instead we ended up relying heavily on PowerShell, the CodePlex BizTalk PowerShell Provider and the BtsWcfServicePublishing component.
When deploying we currently need to do the following:
- Add a couple of DLLS to the GAC
- Add a common BizTalk application with shared send ports, schemas and pipelines
- Add each application with an reference to common and apply bindings.
- Deploy exposed WCF services
- Update the BTSNTsvc.config file (don’t ask..)
Environment configuration
For each BizTalk application we have an associated Environment.xml where all configuration is stored. This is later applied to an exported Binding-file and this way we can always export a new binding-file if we have made smaller non-environement specific changes.
Inside the Environment.xml file we specify the setting to change using XPath and then we have values for each environment using a key. A default value can be specified using the wildcard '*'
The xml-file is structured as follows:

Some settings, e.g.. username and password, are contained within the encoded TransportTypeData-element. The logic for these elements is a bit different, since elements should be created if they don't exist and have an attribute with the value vt=8 (string). We have placed these within an additional element called Decode:

We use this file to create a patched Binding-file for each environment and this file is then placed in a separate environment-subfolder.
Exposed BizTalk WCF services
When you export WCF services using the BizTalk WCF Service Publishing Wizard, a WcfServiceDescription.xml is added to the temp-folder of the actual service. You can also see the XML when running the Wizard.
For our services we need to add an additional WCF logging behavior. Fortunately there is no service-specific configuration in the web.config and you can therefore reuse the same web.config for multiple Biztalk WCF Services. Using the same principle as above, we have a template web.config in a separate folder and then replace the values we need, e.g.. connectionstrings.
Deployment procedure
Deployment is done using two scripts:
CreateDeploymentPackage.ps1: Copies all necessary files and creates bindings and configuration files for all environments into the deployment folder. This can then be moved to each server.
ReDeployAll.ps1: This performs a full re-deploy of all applications and autogenerates exposed webservices. It only has one argument which is the environment and uses this to select the correct binding file.
All PowerShell functions are contained within a common file, FunctionLibrary.ps1, which makes the these two scripts pretty readable. I will not go into details, but have a look at it and hope you get the idea.
A sample can be found at http://www.nebular.dk/files/BTSDeployment.zip. I have done some renaming but it should work 100%.
Additional notes
We do not have any long running processes and can therefore simply delete the entire application and then recreate it. This might not be an option on other projects.
We only deploy to single BizTalk server instances and some tweaking would be necessary to support this scenario, but should be fairly simple to achieve using separate deploy-scripts.
Christian Staerk
81a7b4d8-d641-4b25-a250-9fd3bd50fbcc|1|4.0
BizTalk Server, PowerShell