This post was originally published here
Let’s continue with some deep dive scripts about exporting BizTalk Server bindings, addressing some useful and unsupported scenarios that are impossible to be addressed using out-of-the-box with the standard tools BizTalk Server Administration Console or even with the BTSTask command-line tool included with BizTalk Server.
- How can we easily export a binding file from a list of assemblies?
- How can we easily export a binding file from a Receive Port?
- How can we easily export a binding file from a Send Port?
- And many more
Also recapitulating some of the default scenarios/functionalities already addressed previously done in a different way and with small improvements with PowerShell:
- How can we easily export a binding file from a BizTalk Application?
- How can we easily export a binding file from a specify assembly?
- Using the fully qualified name (FQName) of the assembly.
- Using only the assembly name
Today’s blog post will be about: How to Export BizTalk Server Send Port Binding with PowerShell.
Like Receive Ports, this functionality should be something that should exist in the BizTalk Server Administration Console, but it doesn’t. In some cases we can achieve this in the developing phase using the Visual Studio, while we generate the schemas for LOB systems, for example:
- In the Solution Explorer, right-click a BizTalk project, point to Add, and then click Add Generated Items
- In the Add Generated Items… – <BizTalk ProjectName> dialog box, in the Templates section, click Consume Adapter Service and then click Add
- You should then select the binding you want to use, configure the parameters and the operations you want to do
Along with the LOB Schemas, this will also generate the binding files for the receive port or send port.
So, again, the question that we may ask is: Is there any way that we can easily accomplish this? The response is yes, again, all of this can be fully automated using, for example, PowerShell scripts.
This script, combined with the Receive Ports, is extremely useful if:
- you use several cases of content-based routing (without orchestrations)
- you create new send ports, for example with filters
- new receive port in your environment
and if you don’t want to export/import the full application binding that may affect something that you already have in production.
Like the previous samples, we could fully automate this Binding generation for each environment, but once again, let’s keep it simple and address what is mandatory and easily forgotten. With this PowerShell sample we will be able to generate a binding file for a specific assembly name deployed in my BizTalk Server environment. The script will perform the following tasks:
- Generate a Binding file for 3 environments DEV, QA and PRD
- Changing the NT Group Name for each different environment
- Generate a specific Send Port deployed in your environment
function bts-send-port-exportbindings([string]$bindingFilePath, [string]$appName, [string]$portName, [boolean]$generateDiffEnvBindings) { $portRen = $portName.Replace(" ", "") $taskParams = ” ExportBindings /Destination:$bindingfilePath$appName.$portRen.BindingInfo.xml /ApplicationName:$appName ” #First version: $p = [diagnostics.process]::start(“BTSTask.exe”, $taskParams) Start-Process "BTSTask.exe" $taskParams -Wait $xml = (Get-Content "$bindingfilePath$appName.$portRen.BindingInfo.xml") foreach($RemoveModuleRef in $xml.BindingInfo.ModuleRefCollection.ModuleRef) { $xml.BindingInfo.ModuleRefCollection.RemoveChild($RemoveModuleRef) } foreach($RemoveSendPort in $xml.BindingInfo.SendPortCollection.SendPort) { if($RemoveSendPort.Name -ne $portName) { $xml.BindingInfo.SendPortCollection.RemoveChild($RemoveSendPort) } } foreach($RemoveReceivePort in $xml.BindingInfo.ReceivePortCollection.ReceivePort) { $xml.BindingInfo.ReceivePortCollection.RemoveChild($RemoveReceivePort) } $xml.Save("$bindingfilePath$appName.$portRen.BindingInfo.xml") if($generateDiffEnvBindings) { # QA Binding Info Generation $xml.SelectNodes("//Host") | % { $_.NtGroupName = $global:qaNTGroupName } $xml.Save("$bindingfilePath$appName.$portRen.QA.BindingInfo.xml") # PRD Binding Info Generation $xml.SelectNodes("//Host") | % { $_.NtGroupName = $global:prdNTGroupName } $xml.Save("$bindingfilePath$appName.$portRen.PRD.BindingInfo.xml") } }THIS POWERSHELL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
You can download the full script from here: Export BizTalk Server Send Port Binding with PowerShell
The post BizTalk Bindings Exportation: How to Export BizTalk Server Send Port Binding with PowerShell appeared first on BizTalk360.