Easy BizTalk Configuration and Deployment with multiple environments

9. June 2011

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:

image

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:

image

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  

BizTalk Server, PowerShell

BizTalk SSO oddity

7. June 2011

After importing some bindings, I discovered that I was unable to dive into the configuration on some of the receive port (BizTalk 2009).

I got the following error:

The mapping does not exist. For config store applications,
the config info has not been set.

 I didnt see any specific errors, and by a lucky shot I decided to restart the SSO service, and the problem was solved.


Michael Høtoft  

BizTalk Server

Manually adding the BizTalk Powershell Provider extension

6. June 2011

After trying a gazillion times to install the BizTalk powershell adapter (without errors) and being unable to uninstall it. I was forced to look for alternate solutions.

I came up with the idea of manually registering the extension based upon the installed Dll's.

And it worked like a charm:

 

PS C:\Program Files (x86)\BizTalkFactory PowerShell Provider> 

set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil

installutil .\BizTalkFactory.PowerShell.Extensions.dll

Add-PSSnapin -Name BizTalkFactory.PowerShell.Extensions

get-PSsnapin -registered

expected result :

Name        : BizTalkFactory.PowerShell.Extensions
PSVersion   : 2.0
Description : Windows PowerShell CmdLets and Provider for Microsoft Biztalk Serv

 

Addition : Elevated priveledges is not the issue. But it's definently worth trying before anything else, if you tend to forget it from time to time like I do ;)

 


Michael Høtoft  

BizTalk Server, Sharepoint Server ,

Add XML comment via Powershell

6. June 2011

Just a quick post regarding adding comments to XML files in powershell. ie. Build versions in config files etc.

 

 

param([string]$configfile="C:\Users\mh0030\Documents\PowerShell\CommentTestFile.xml", [string]$comment="My default comment")

$doc = [xml](get-content $configfile)

$root = $doc.SelectSingleNode("/MyRoot")
$comment = $doc.CreateComment($comment)
$doc.InsertBefore($comment,$root)
$outFile = (Split-Path -Parent $configfile) + "\outfile.xml"

$doc.save($outFile)


The two important parts are; the navigator element, in this case $root as selected by "/MyRoot" and the other part is how you want to insert the comment. InsertAfter, InsertBefore, AppendChild.
See the .net documentation for further details here : http://msdn.microsoft.com/en-us/library/system.xml.xmldocument_methods.aspx

 


Michael Høtoft  

Sharepoint Server ,