by Sandro Pereira | May 15, 2019 | BizTalk Community Blogs via Syndication
On the last blog post and PowerShell sample we addressed, for the first time in the series of posts, a way to aggregate several binding exportations in a unique binding file based on a list of assemblies with fully qualified names (FQName):
- How can we easily export a binding file from a list of assemblies?
Today’s blog post will be similar, but instead of using the FQName, we will be using the assembly name only: How to Export BizTalk Server Resource Bindings from a List of Assembly Names with PowerShell
In other words, instead of generating a specific binding file for each resource: Receive Port, Send Port or Assembly, we will be generating a unique binding file that will include all of this information so it can easily be handled.
Recapping also the samples we have shared until now:
And to unveil the last chapter of this series that we will be publishing soon:
- How can we easily export a binding file from a list of Receive Ports and/or Send Ports?
Just 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 unique binding file for a list of specific assemblies 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 unique binding file, instead of having separated binding files for each assembly
function bts-list-resource-exportbindings-by-assembly-name([string]$bindingFilePath, [string]$appName, [string]$listAssemblyName, [boolean]$generateDiffEnvBindings)
{
#splits all the assemblies by |
$list = $listAssemblyName.Split("|")
$finalBinding = (Get-Content "C:TempTemplateBindingInfo.xml")
$moduleRefNode = $finalBinding.SelectSingleNode("BindingInfo/ModuleRefCollection")
$sendPortNode = $finalBinding.SelectSingleNode("BindingInfo/SendPortCollection")
$receivePortNode = $finalBinding.SelectSingleNode("BindingInfo/ReceivePortCollection")
$displayName = 'assemblyName'
$appsList=New-Object System.Collections.ArrayList
$assemblyListFQN = New-Object System.Collections.ArrayList
$appsList = BTSTask.exe ListApp /ApplicationName:$appName
#region Add FQN to list
foreach($string in $appsList)
{
#region Get Assembly Fully Qualified Name
$list = $listAssemblyName.Split("|")
foreach($element in $list)
{
if($string.Contains('-'))
{
if($string.Split('-')[1].Split('"')[1] -eq "System.BizTalk:BizTalkAssembly")
{
foreach($element in $list){
if($string.Split('-')[2].Split('"')[1].StartsWith($element))
{
if(!$assemblyListFQN.Contains($string.Split('-')[2].Split('"')[1])){
$assemblyListFQN.Add($string.Split('-')[2].Split('"')[1]);
#display name Set
}
}
}
}
}
}
#endregion
}
#endregion
#loop assemblies
foreach($string in $assemblyListFQN)
{
$dllName = $string.Substring(0, $string.IndexOf(','))
$taskParams = ” ExportBindings /Destination:$bindingfilePath$appName.$dllName.BindingInfo.xml /AssemblyName:""$string"" ”
Start-Process "BTSTask.exe" $taskParams -Wait
$xml = (Get-Content "$bindingfilePath$appName.$dllName.BindingInfo.xml")
foreach($moduleRef in $xml.BindingInfo.ModuleRefCollection.ModuleRef)
{
$node = $finalBinding.ImportNode(($moduleRef), $true);
$moduleRefNode.AppendChild($node);
}
foreach($sendPort in $xml.BindingInfo.SendPortCollection.SendPort)
{
$node = $finalBinding.ImportNode(($sendPort), $true);
$sendPortNode.AppendChild($node);
}
foreach($receivePort in $xml.BindingInfo.ReceivePortCollection.ReceivePort)
{
$node = $finalBinding.ImportNode(($receivePort), $true);
$receivePortNode.AppendChild($node);
}
}
$finalBinding.Save("$bindingfilePath$appName.BindingInfo.xml")
#generate different Environments Bindings
if($generateDiffEnvBindings)
{
$xml = (Get-Content "$bindingfilePath$appName.BindingInfo.xml")
# QA Binding Info Generation
$xml.SelectNodes("//Host") | % {
if(!$_.Attributes['xsi:nil'].Value)
{
$_.NtGroupName = $global:qaNTGroupName
}
}
$xml.Save("$bindingfilePath$appName.QA.BindingInfo.xml")
# PRD Binding Info Generation
$xml.SelectNodes("//Host") | % {
if(!$_.Attributes['xsi:nil'].Value)
{
$_.NtGroupName = $global:prdNTGroupName
}
}
$xml.Save("$bindingfilePath$appName.PRD.BindingInfo.xml")
}
}
THIS POWERSHELL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
To be honest, I think this is the less useful script because it is not that much practical use, and also it will have several limitations when we have several and different versions of the same published DLL. But, it can be very useful and practical in situations where we can guarantee that we have only one DLL version published in our environment.
You can download the full script from here: Export BizTalk Resource Bindings from a List of Assembly Names with PowerShell
The post BizTalk Bindings Exportation: How to Export BizTalk Server Resource Bindings from a List of Assembly Names with PowerShell appeared first on BizTalk360.
by Sandro Pereira | May 1, 2019 | BizTalk Community Blogs via Syndication
Until now, we have been addressing single operations, like generating binding files for one Receive or Send Port port or a single Assembly. Some of these default operations can be achieved with out-of-the-box tools (BizTalk Server Administration Console or even with BTSTask command-line tool included with BizTalk Server), other more advanced scenarios extend the default functionalities:
From now on, we will be addressing some of the previous features described in this series of posts, but this time aggregating several operations for example:
- How can we easily export a binding file from a list of assemblies?
- By fully qualified name (FQName)
- By assembly names
- How can we easily export a binding file from a list of Receive Ports?
- How can we easily export a binding file from a list of Send Ports?
In other words, instead of generating a specific binding file for each resource: Receive Port, Send Port or Assembly, we will be generating a unique binding file that will include all this information, so it can easily be handled.
Today’s blog post will be about: How to Export BizTalk Server Resource Bindings from a List of Assemblies FQName with PowerShell.
Out-of-the-box, we can export a binding file for a specific assembly which is deployed in your BizTalk Server environment. But if you have 10 assemblies then you will be forced to generate them one by one and you will end up with:
- 10 different binding files that you can provide to your administration team
- Or manually merge them into one and provide them to your administration team
This manual intervention, besides being monotonous, boring and time-consuming is subject to many failures. So the normal question is, is there any way that we can improve this experience? And the response is yes, all of this can be fully automated using, for example, PowerShell scripts.
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 unique binding file for a list of specific assemblies deployed in my BizTalk Server environment. The script will take care of 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 unique binding file, instead of having separated binding files for each assembly
function bts-list-resource-exportbindings-by-assembly-fqname([string]$bindingFilePath, [string]$appName, [string]$listAssemblyFQName, [boolean]$generateDiffEnvBindings)
{
$finalBinding = (Get-Content "C:TempBTSTemplateBindingInfo.xml")
$moduleRefNode = $finalBinding.SelectSingleNode("BindingInfo/ModuleRefCollection")
$sendPortNode = $finalBinding.SelectSingleNode("BindingInfo/SendPortCollection")
$receivePortNode = $finalBinding.SelectSingleNode("BindingInfo/ReceivePortCollection")
$list = $listAssemblyFQName.Split("|")
foreach($element in $list)
{
$dllName = $element.Substring(0, $element.IndexOf(','))
$taskParams = ” ExportBindings /Destination:$bindingfilePath$appName.$dllName.BindingInfo.xml /AssemblyName:""$element"" ”
Start-Process "BTSTask.exe" $taskParams -Wait
$xml = (Get-Content "$bindingfilePath$appName.$dllName.BindingInfo.xml")
foreach($moduleRef in $xml.BindingInfo.ModuleRefCollection.ModuleRef)
{
$node = $finalBinding.ImportNode(($moduleRef), $true);
$moduleRefNode.AppendChild($node);
}
foreach($sendPort in $xml.BindingInfo.SendPortCollection.SendPort)
{
$node = $finalBinding.ImportNode(($sendPort), $true);
$sendPortNode.AppendChild($node);
}
foreach($receivePort in $xml.BindingInfo.ReceivePortCollection.ReceivePort)
{
$node = $finalBinding.ImportNode(($receivePort), $true);
$receivePortNode.AppendChild($node);
}
}
$finalBinding.Save("$bindingfilePath$appName.BindingInfo.xml")
if($generateDiffEnvBindings)
{
$xml = (Get-Content "$bindingfilePath$appName.BindingInfo.xml")
# QA Binding Info Generation
$xml.SelectNodes("//Host") | % {
$_.NtGroupName = $global:qaNTGroupName
}
$xml.Save("$bindingfilePath$appName.QA.BindingInfo.xml")
# PRD Binding Info Generation
$xml.SelectNodes("//Host") | % {
$_.NtGroupName = $global:prdNTGroupName
}
$xml.Save("$bindingfilePath$appName.PRD.BindingInfo.xml")
}
}
THIS POWERSHELL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
You can download the full script from here: Export BizTalk Resource Bindings from List of Assemblies FQName with PowerShell
The post BizTalk Bindings Exportation: How to Export BizTalk Server Resource Bindings from a List of Assemblies FQName with PowerShell appeared first on BizTalk360.
by Sandro Pereira | Apr 30, 2019 | BizTalk Community Blogs via Syndication
Let’s go for the third PowerShell sample in a series of posts that, once again, I will be addressing some of the real case scenarios that we may face daily:
Today’s blog post will be about: How to Export BizTalk Server Resource Bindings by Assembly Name (instead of the FQName) with PowerShell.
This is extremely similar to the previous one, but instead of using the fully qualified name (FQName) of the assembly, we will be using only the assembly name. Nevertheless, this small change will have a significant technical impact on the way we can archive this goal.
Just for getting started, and for you to be aware, this is impossible to do out-of-the-box with the standard tools:
- BizTalk Server Administration Console
- Or even with BTSTask command-line tool included with BizTalk Server. This tool provides the option for you to export binding information to a .xml file by using the ExportBindings command:
- BTSTask ExportBindings /Destination: value [/GroupLevel] [/ApplicationName:value] [/AssemblyName:value ] | [/GlobalParties] [/Server:value] [/Database:value]
- /ApplicationName: Name of the application from which to export bindings.
- /AssemblyName: a Locally unique identifier (LUID) of the assembly from which to export bindings.
So, if you want to do something outside the box this is were the fun and challenges really start to appear and the question that we may ask is: Is there any way that we can accomplish this and at the same time improve the experience, similar to the previous examples? The response is that yes, all of this can be fully automated using, for example, PowerShell scripts.
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 which is deployed in my BizTalk Server environment.
Generate a Binding file for 3 environments DEV, QA and PRD:
- Changing the NT Group Name for each different environment
- Generate a Binding file for each version of the assembly name found deployed
function bts-resource-exportbindings-by-assembly-name([string]$bindingFilePath, [string]$appName, [string]$assemblyName, [boolean]$generateDiffEnvBindings)
{
$list= BTSTask.exe ListApp /ApplicationName:$appName
$list |foreach {
if ($_ -like '*Resource:*')
{
if($_.Split('-')[1].Split('"')[1] -eq "System.BizTalk:BizTalkAssembly")
{
$varAssemblyFQName = $_.Split('-')[2].Split('"')[1]
$verison = $_.Split('-')[2].Split('"')[1].Split("=")[1].Split(",")[0]
if($varAssemblyFQName -like "*"+ $assemblyName + "*")
{
$taskParams = ” ExportBindings /Destination:$bindingfilePath$appName.$assemblyName.$verison.BindingInfo.xml /AssemblyName:""$varAssemblyFQName"" ”
Start-Process "BTSTask.exe" $taskParams -Wait
if($generateDiffEnvBindings)
{
$xml = (Get-Content "$bindingfilePath$appName.$assemblyName.$verison.BindingInfo.xml")
# QA Binding Info Generation
$xml.SelectNodes("//Host") | % {
$_.NtGroupName = $global:qaNTGroupName
}
$xml.Save("$bindingfilePath$appName.$assemblyName.$verison.QA.BindingInfo.xml")
# PRD Binding Info Generation
$xml.SelectNodes("//Host") | % {
$_.NtGroupName = $global:prdNTGroupName
}
$xml.Save("$bindingfilePath$appName.$assemblyName.$verison.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 Resource Bindings by Assembly Name with PowerShell
The post BizTalk Bindings Exportation: How to Export BizTalk Server Resource Bindings by Assembly Name with PowerShell appeared first on BizTalk360.
by Sandro Pereira | Apr 23, 2019 | BizTalk Community Blogs via Syndication
This is the second PowerShell sample in a series of samples that I will do on this topic addressing some of the real case scenarios that we may face daily:
Today’s blog post will be about: How to Export BizTalk Server Resource Bindings by Assembly FQ Name with PowerShell.
Exporting a BizTalk Server Application binding is, at first sight, a simple and quick task that can be done using the BizTalk Server Administration Console:
- Click Start, click All Programs, click Microsoft BizTalk Server 20xx, and then click BizTalk Server Administration
- In the console tree, expand BizTalk Server Administration, expand the BizTalk Group, and then expand Applications
- Right-click the application whose assembly is associated, and you want to export the bindings, or simply right-click on the Applications, point to Export, and then click Bindings…
- On the Export Bindings page, in Export to file, type the absolute path of the .xml file to which to export the bindings
- Ensure that Export bindings from the select assembly is selected, and then click OK

But, again, even in all simple tasks we may encounter challenges that require us to perform some monotonous and boring manual operations that consume some of our precious time and are always subject to failures.
Once again, the steps that I described above only generate the binding files from that specific environment, maybe or normally this all start in development, but we also will need to generate the same bindings for production, and for that we normally need to open the binding file and replace/fix the differences for each different environment… which is normally a tedious operation. What we need to replace is mainly:
- The URI’s – it should be fixed but it is not mandatory you can fix them directly on the environment after you import the Binding if you know what you are doing
- The host instances – not mandatory if you have the same host and host instances names across all your different environments as best practices will tell you to do
- The NT Group Name associated in the Services (Orchestrations) – according to security best practices you shouldn’t use the same BizTalk Groups in different environments, so in this case, if you follow this best practice, you need mandatory to change these parameters in your binding file
Normally, everyone changes the URI’s but neglecting the other parameters may be causing problems during the Binding import.
- So, the question is: Is there any way that we can improve this experience? And the response is that yes, all of this can be fully automated by using, for example, PowerShell scripts.
Like the previous sample, 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 for a specific assembly, with a fully qualified name, deployed in my BizTalk Server environment, I can easily:
- Generate a Binding file for 3 environments DEV, QA and PRD
- Changing the NT Group Name for each different environment
function bts-resource-exportbindings-by-assembly-fqname([string]$bindingFilePath, [string]$appName, [string]$assemblyFQName, [boolean]$generateDiffEnvBindings)
{
$dllName = $assemblyFQName.Substring(0, $assemblyFQName.IndexOf(','))
$taskParams = ” ExportBindings /Destination:$bindingfilePath$appName.$dllName.BindingInfo.xml /AssemblyName:""$assemblyFQName"" ”
Start-Process "BTSTask.exe" $taskParams -Wait
if($generateDiffEnvBindings)
{
$xml = (Get-Content "$bindingfilePath$appName.$dllName.BindingInfo.xml")
# QA Binding Info Generation
$xml.SelectNodes("//Host") | % {
$_.NtGroupName = $global:qaNTGroupName
}
$xml.Save("$bindingfilePath$appName.$dllName.QA.BindingInfo.xml")
# PRD Binding Info Generation
$xml.SelectNodes("//Host") | % {
$_.NtGroupName = $global:prdNTGroupName
}
$xml.Save("$bindingfilePath$appName.$dllName.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 Resource Bindings by Assembly FQName with PowerShell
The post BizTalk Bindings Exportation: How to Export BizTalk Server Resource Bindings by Assembly FQ Name with PowerShell appeared first on BizTalk360.