Automating Hosts, Host Instances and Adapter Handlers configuration in BizTalk 2006

Hi Folks,

I am going to be focusing on automating BizTalk Server 2006 configuration for the creation of Adapters, Hosts and Host Instances. The current project I am working on, we use multiple Host Instances and various send/receive adapter for the applications we have installed on BizTalk Server.


BizTalk has some nice built in features to make our lives easier, the following are the main features we use as BizTalk developers or administrators when deploying a clean solution.

  • Binding Files – Automate binding your logical ports in Orchestrations to physical ports, creating send and receive ports and linking them to Adapter handlers via Host Instances.

  • Policy Files – Business Rule Engine installation of Vocabularies, Rules and Policies.

  • BTSNTSvc.exe.config – A place where you can add custom settings, fine tune and retrieve them programmatically, I prefer Enterprise Single Sign-On database for this, more about that in later blogs.

What about Hosts, Host Instances and Adapters?

Today I will be focusing on automating Host Instances and Adapter Installation and provide sample code that can be used, since it is not on the above list.


This blog is to introduce you to the power of combining C# and WMI and creating a custom admin tool for your BizTalk 2006 environment, to fill in the gaps.


Before we start let’s focus on how one would actually go about in setting up Host Instances and Adapters. The current tool used for this is Microsoft BizTalk Server 2006 Administrative Console.

  1. Create a Host
  2. Create a Host Instance and link it to the Host
  3. Create a Send/Receive Handler for each adapter that will be using the Host

So, you if you use 3 Adapters (MSMQ, File and Soap), you will have allot of work set out for you, and this can become rather tedious when rebuilding your development or test environment.

So let’s get down and dirty!

Technical Details

I am going to use a very basic example, where we want a different service process to manage Orchestrations, Send Ports and Receive Ports. So in a nutshell you can have a BizTalk Application use different host instances for hosting Send/Receive Ports and Orchestrations, for performance, since you allocate more threads to a single BizTalk application to use

It is common for people to get confused with this sort of grouping, the above is for performance. Another grouping that one can do is by Application, this is more for management and deployment benefits. Microsoft has mentioned that it is efficient to sometimes group common Artifacts in BizTalk at the application level for ease of deployment. So for example your entire Schema’s in one application, all Orchestrations in another and so on.


bts_WMINameSpace = @"root\MicrosoftBizTalkServer";

bts_HostSettingNameSpace = "MSBTS_HostSetting";

bts_ServerAppTypeNameSpace = "MSBTS_ServerHost";

bts_HostInstanceNameSpace = "MSBTS_HostInstance";

bts_AdapterSettingNameSpace = "MSBTS_AdapterSetting";

bts_ReceiveHandlerNameSpace = "MSBTS_ReceiveHandler";

bts_SendHandlerNameSpace = "MSBTS_SendHandler2";

Class Diagram

Let’s be honest, all you OO geeks out there can probably do some encapsulation and all the other nifty tricks to make this program GREAT! However, I have kept the code pure functional.


I have assumed your BizTalk server is in windows domain called Dev, and that you follow the best practices and use domain groups for the configuration of your Host Instances. The configuration file has the following, which you will need to change to suite your environment.

username="Dev\BizTalkSVC" password="mypassword"

ntgroupname="Dev\BizTalk Application Users"


The code generates a command console application, and the xml configuration file is required to be in the same directory as the executable.

The command to type is BizTalkAdministration.exe and it will then look for the configuration file in the same directory. Simple, no arguments etc.

Configuration File

Below is a copy of the configuration file, you can see that we want to create:

  • Four Hosts
  • 4 Host Instances
  • For each instance a corresponding Send or Receive Handler or both

<?xml version="1.0" encoding="utf-8"?>



<Host hostname="Orchestrations" ntgroupname="Dev\BizTalk Application Users" isdefault="false" hosttracking="false" authtrusted="true" hosttype="1"/>

<Host hostname="RecievePorts" ntgroupname="Dev\BizTalk Application Users" isdefault="false" hosttracking="false" authtrusted="true" hosttype="1"/>

    <Host hostname="SendPorts" ntgroupname="Dev\BizTalk Application Users" isdefault="false" hosttracking="false" authtrusted="true" hosttype="1"/>

    <Host hostname="WorkFlowEngine" ntgroupname="Dev\BizTalk Application Users" isdefault="false" hosttracking="false" authtrusted="true" hosttype="1"/>



<HostInstance servername="." hostname="Orchestrations" username="Dev\BizTalkSVC" password="mypassword" startinstance="true"/>

<HostInstance servername="." hostname="RecievePorts" username="Dev\BizTalkSVC" password="mypassword" startinstance="true"/>

    <HostInstance servername="." hostname="SendPorts" username="Dev\BizTalkSVC" password="mypassword" startinstance="true"/>

    <HostInstance servername="." hostname="WorkFlowEngine" username="Dev\BizTalkSVC" password="mypassword" startinstance="true"/>



<Adapter name="FILE" type="FILE" comment="FILE adapter">

<ReceiveHandler hostname="Orchestrations"/>

<ReceiveHandler hostname="RecievePorts"/>

<ReceiveHandler hostname="WorkFlowEngine"/>

<SendHandler hostname="Orchestrations"/>

<SendHandler hostname="RecievePorts"/>

     <SendHandler hostname="WorkFlowEngine"/>


<Adapter name="MSMQ" type="MSMQ" comment="MSMQ adapter">

<ReceiveHandler hostname="WorkFlowEngine"/>

<SendHandler hostname="WorkFlowEngine"/>


<Adapter name="SOAP" type="SOAP" comment="SOAP adapter">

<SendHandler hostname="WorkFlowEngine"/>

<SendHandler hostname="SendPorts"/>

<SendHandler hostname="Orchestrations"/>






Here is the result of your hard work, if you run the application with the default settings, and of course you remembered to change the account and group settings in the configuration file.

Hosts Created

Host Instances Created

TIP: Notice the Not installed status above, this usually occurs if you provide and incorrect username and password in the configuration file, since it tries to create a windows service for you. To solve it, ensure you get your username and password right first time; else it is time to get out the helmets, elbow pads and knee pads for full contact double clicking and fixing the account credentials.

File Adapters

Soap Adapters

MSMQ Adapters


Download Source Code

The sample code for this can be found here:

Developed using Microsoft Visual Studio 2005 in C#.


I hope you found this blog helpful and wish you the best of times with the new tool.

  • Uncategorized

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s