This post was originally published here
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:
- How can we easily export a binding file from a BizTalk Application?
- How can we easily export a binding file for a specific assembly?
- Using the fully qualified name (FQName) of the assembly
- Using only the assembly name
- 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
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.
- BTSTask ExportBindings /Destination: value [/GroupLevel] [/ApplicationName:value] [/AssemblyName:value ] | [/GlobalParties] [/Server:value] [/Database:value]
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.