This post was originally published here

In the past, I wrote a blog post about Configuring BizTalk Server Host and Host Instances according to some of the Best Practices and I already have available online two PowerShell scripts for you to download: PowerShell to Configure BizTalk Server Host and Host Instances and PowerShell to Configure BizTalk Server 2013/2013 R2 Host and Host Instances.

The problem of these two scripts is that they only do 90% of the work and they are intended to be used on “day zero” of your environment, i.e., after you finish installing your environment. Don’t get me wrong, you can still use it if you have your environment up and running for a long time but in this case, you will get several error messages while the script tries to delete the handlers associated with the adapters and the reason is that you probably have already several receive and send port that is configured to use the existing “default” handler: “BizTalkServerApplication“.

For this reason, I decided to update my previous script, of course, optimize it to BizTalk Server 2016 (but it can be executed in BizTalk Server previous versions), and add to it more functionalities:

  • Configure the Default Send Handler as the Send Handler for each existing static and Dynamic Send Ports
  • Configure Receive Handlers from all the existing Receive locations

With these missing functionalities added the script is now working 100% and you can use it on “day zero” of your environment or when in an existing environment with existing BizTalk Applications configured and running.

The only catch is, if you already have BizTalk Application running in your environment, in order for the script to do all the steps you may need to stop all your BizTalk Applications, special the ones that have orchestrations deployed. And one of the reasons why is that for example if you cannot change the Receive or Send handler of ports that are bind to an orchestration, if, the orchestration is running.

What is Host and a Host Instances?

The BizTalk Host is a logical process and security boundary within 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 work of the host.

In another hand, a 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 service account of the host instance belongs to the security group of the host. 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 for a specific instance of an adapter.

The default BizTalk Server configuration will only create one in-process host, “BizTalkServerApplication”, that will be associated as a receive and send adapter handler for all of the installed adapters, with the exception of HTTP, SOAP, WCF-BasicHttp, WCF-WSHttp and WCF-CustomIsolated adapter receive handlers that can only be running in an isolated host.

How can I automate this task?

Windows PowerShell is a Windows command-line shell designed especially for system administrators and can be used by BizTalk administrators to help them in automating tasks.

This is a simple script that will configure the following components in your environment:

  • Create Host and Host Instance according to some of the best practices: two Receive host and host instances (one 32-bits and one 64-bits); two Send host and host instances (one 32-bits and one 64-bits); 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 ports present in your environment

THIS POWERSHELL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.

The script can be found and download on Microsoft TechNet Gallery:

Host, Host Instances and Adapter HandlersPowerShell to Configure BizTalk Server 2016 Host, Host Instances and Handlers (30 KB)
Microsoft | TechNet Gallery

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community. View all posts by Sandro Pereira