Background and Existing Scripts
In the past, I published a blog post about configuring BizTalk Server Hosts and Host Instances according to best practices. I also shared two PowerShell scripts that you can still download:
- PowerShell to Configure BizTalk Server Host and Host Instances
- PowerShell to Configure BizTalk Server 2013/2013 R2 Host and Host Instances
These scripts work well, but they were designed mainly for day‑zero environments. In other words, they assume you have just finished installing BizTalk Server and have not yet deployed applications.
Limitations of the Original Scripts
The main limitation is that these scripts complete about 90% of the work. You can still run them in an environment that has been live for a long time, but you will likely see multiple errors.
These errors occur when the script tries to delete adapter handlers. In most production environments, receive locations and send ports already use the default handler, BizTalkServerApplication. Because of that, the script cannot remove handlers that are actively in use.
Script Improvements and New Capabilities
To solve this problem, I updated the original script and optimized it for BizTalk Server 2016. Even so, you can still run it on earlier BizTalk versions. I also added new functionality to cover the missing 10%.
The updated script now does the following:
- Configures the default send handler for all existing static and dynamic send ports
- Reconfigures receive handlers for all existing receive locations
With these improvements, the script now completes 100% of the configuration. You can safely run it on day zero or in an existing environment with deployed, running BizTalk applications.
Important Considerations Before Running the Script
There is one important requirement to keep in mind. If your environment already runs BizTalk applications, you may need to stop all BizTalk applications before executing the script.
This step is especially important if your applications include orchestrations. BizTalk does not allow you to change receive or send handlers for ports that are bound to running orchestrations.
📝 One-Minute Brief
A practical article that explains best practices for managing BizTalk Server host instances and adapter handlers using PowerShell. It shows how automation can reduce configuration errors, improve consistency across environments, and simplify BizTalk administration tasks.
What is a Host and a Host Instance?
The BizTalk Host is a logical process and security boundary within the BizTalk Server that represents a logical set of zero or more run-time processes in which you can deploy BizTalk Server services and artifacts (such as adapter handlers, receive locations, and orchestrations). Each host has a security group assigned to it and may contain multiple host instances, each on an individual machine, that perform the host’s work.
In another hand, a BizTalk host instance is the physical instance of a host on a computer running BizTalk Server. Each host instance belongs to exactly one host, and the host instance’s service account belongs to the host’s security group. The security group may be used to grant permissions to physical resources, such as databases, for use by any host instances in the host.
What is an Adapter Handler?
An adapter handler is an instance of a BizTalk host in which the adapter code runs. When you specify a send or receive handler for an adapter, you are specifying which host instance the adapter code will run in the context of. An adapter handler is responsible for executing the adapter and contains properties specific to a given instance.
The default BizTalk Server configuration will create only one in-process host, BizTalkServerApplication, which will be associated as a receive and send adapter handler for all installed adapters, except for the HTTP, SOAP, WCF-BasicHttp, WCF-WSHttp, and WCF-CustomIsolated adapter receive handlers, which can only run in an isolated host.
How can I automate this task?
Windows PowerShell is a Windows command-line shell designed for system administrators and can be used by BizTalk administrators to automate tasks.
This is a simple script that will configure the following components in your environment:
- Create a Host and a Host Instance according to some of the best practices: two Receive hosts and host instances (one 32-bit and one 64-bit); two Send hosts and host instances (one 32-bit and one 64-bit). One Host and Host Instance to process Orchestrations, and one Host and Host Instance for tracking.
- Create Receive and Send Handlers for each adapter.
- And finally, associate the correct Receive and Send Handlers to each existing receive and send port present in your environment.
Download
THIS POWERSHELL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
You can download PowerShell to Configure BizTalk Server 2016 Host, Host Instances, and Handlers from GitHub here:
Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son.
Hi Sandros,
Did you make this work with BTS2020 using GMSA’s? Or would you recommend another approach.
Hi Charles, I publish today a new version supporting gMSA check the script here https://blog.sandro-pereira.com/2020/06/30/biztalk-server-2020-powershell-to-configure-host-host-instances-and-adapter-handlers-according-to-some-of-the-best-practices/