As happens almost every year on my birthday, I like to write a small gift for the BizTalk community. This time, I want to focus on automating a common administrative task: configuring default Dynamic Send Port handlers using PowerShell.
Manually configuring these settings can be time‑consuming and error‑prone, especially in environments with multiple adapters and hosts. Automation helps standardize configurations and saves valuable time.
Configurable Dynamic Send Port Handlers in BizTalk Server
Starting with BizTalk Server 2013, Microsoft introduced an important feature: configurable Dynamic Send Port handlers.
With this feature, you can configure a specific adapter send handler for each installed adapter when creating a Dynamic Send Port. By default, BizTalk assigns the adapter’s default send handler. This behavior applies to both One‑Way and Solicit‑Response Dynamic Send Ports.
In earlier BizTalk versions, Dynamic Send Ports always ran on the adapter’s default host. At that time, administrators had no way to change this behavior, which often limited flexibility and performance tuning.
📝 One-Minute Brief
📝 One-Minute Brief
One-Minute Brief (TL;DR):
[/summary]
Common Challenges with Dynamic Send Port Handlers
While these new features add flexibility, they also introduce several challenges, especially for BizTalk Administrators.
Default Handler Issues in New Environments
When you install a new BizTalk environment and enable EDI features, BizTalk automatically creates a dynamic send port called ResendPort. By default, BizTalk assigns BizTalkServerApplication as the send handler for all adapters.
This default behavior often conflicts with environments that follow best practices, such as using dedicated hosts for specific workloads.
Dedicated Hosts and Handler Reconfiguration
In many environments, administrators create dedicated host instances for receiving, sending, processing orchestrations, and tracking. Once you do that, you must associate each adapter with the correct receive or send handler.
However, if you want to remove BizTalkServerApplication as a send handler, BizTalk does not allow it immediately. First, you need to:
- Reconfigure the default Dynamic Send Port handlers for every dynamic send port
- Assign the correct default send handler
- Only then, remove BizTalkServerApplication as a send handler from each adapter
These steps require careful coordination and manual effort.
Impact of Installing New Adapters
The same issue appears when you install a new adapter. BizTalk automatically assigns the default group host as the send handler for that adapter.
As a result, BizTalk also updates the default send handler for that adapter across all existing dynamic send ports. Consequently, administrators must once again manually update every affected dynamic send port.
Why Automation Matters
All these tasks take time. After repeating them a few times, they also become frustrating and error‑prone. Although manual configuration works, it does not scale well across environments.
This is exactly where PowerShell automation becomes valuable.
So how can we automate tasks? and reuse them whenever necessary, and at the same time save significant time for other tasks?
Using PowerShell is a good option. Windows PowerShell is a Windows command-line shell designed especially for system administrators and can be used by BizTalk administrators to help them automate repetitive tasks or tasks that are time-consuming to perform manually.
This is a simple script that allows you to configure the default send handlers associated with all the existing Dynamic Send ports in your environment:
[string] $sendHost32bits = "BizTalkServerSend32Host"
[string] $sendHost64bits = "BizTalkServerSendHost"
$catalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
$catalog.ConnectionString = "SERVER=$bizTalkDbServer;DATABASE=$bizTalkDbName;Integrated Security=SSPI"
foreach($sendPort in $catalog.SendPorts)
{
if($sendPort.IsDynamic -eq' True')
{
# A Dynamic send port was found so now we need to configure the send handler as desired
# 64 bits adapters
# Changing the default send handlers of the dynamic port
$sendPort.SetSendHandler("FILE", $sendHost64bits)
$sendPort.SetSendHandler("HTTP", $sendHost64bits)
$sendPort.SetSendHandler("MQSeries", $sendHost64bits)
$sendPort.SetSendHandler("MSMQ", $sendHost64bits)
$sendPort.SetSendHandler("SB-Messaging", $sendHost64bits)
$sendPort.SetSendHandler("SFTP", $sendHost64bits)
$sendPort.SetSendHandler("SOAP", $sendHost64bits)
$sendPort.SetSendHandler("WCF-BasicHttp", $sendHost64bits)
$sendPort.SetSendHandler("WCF-BasicHttpRelay", $sendHost64bits)
$sendPort.SetSendHandler("WCF-Custom", $sendHost64bits)
$sendPort.SetSendHandler("WCF-NetMsmq", $sendHost64bits)
$sendPort.SetSendHandler("WCF-NetNamedPipe", $sendHost64bits)
$sendPort.SetSendHandler("WCF-NetTcp", $sendHost64bits)
$sendPort.SetSendHandler("WCF-NetTcpRelay", $sendHost64bits)
$sendPort.SetSendHandler("WCF-SQL", $sendHost64bits)
$sendPort.SetSendHandler("WCF-WebHttp", $sendHost64bits)
$sendPort.SetSendHandler("WCF-WSHttp", $sendHost64bits)
$sendPort.SetSendHandler("Windows SharePoint Services", $sendHost64bits)
# 32 bits adapters
# SMTP Supports 64 bits but I want to run in 32 because of the MIME/SMIME Encoder
$sendPort.SetSendHandler("FTP", $sendHost32bits)
$sendPort.SetSendHandler("SMTP", $sendHost32bits)
$sendPort.SetSendHandler("SQL", $sendHost32bits)
}
}
$catalog.SaveChanges()
Prerequisites for this script: The host, host instances, and send handlers need to be already configured in your environment before you run the script.
Download
THIS POWERSHELL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
You can download PowerShell to configure Default Dynamic Send Port Handlers for each Adapter 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 Sandro, I’m strugling with BizTalk 2016 to use a dynamic send port for SFTP – meaning it will go throught the WinSCPnet.
I set the usual stuff
Logical port side:
PrtOutbound(Microsoft.XLANGs.BaseTypes.Address) = varEndpoint_uri;
PrtOutbound(Microsoft.XLANGs.BaseTypes.TransportType) = varMedia_type;
Messae properties
msgDispatch = msgLoad;
msgDispatch(BTS.OutboundTransportType) = varMedia_type;
msgDispatch(SFTP.ClientAuthenticationMode) = “Password”;
msgDispatch(SFTP.UserName) = varSftp_login;
msgDispatch(SFTP.Password) = varSftp_password;
msgDispatch(SFTP.EncryptionCipher) = “Auto”;
msgDispatch(SFTP.SSHServerHostKeyFingerPrint) = “”;
msgDispatch(SFTP.AccessAnyServerHostKey) = true;
msgDispatch(SFTP.AppendIfExists) = varSftp_appendIfExists;
msgDispatch(SFTP.TargetFileName) = varSftp_fileName;
… and I get the same error:
System.ArgumentException: SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp,
but SessionOptions.SshHostKeyFingerprint is not set.
I tried with and without fingerprint, with and without acceptance of any server’s fingerprint.
It ssems that my values at the message context are not being taken in account.
The logical send port type is System.Xml (i’m implementing a file dispatcher) and the pipeline is passthrough.
What am I missing?
I would really preciate your help.
Thanks in advance