This post was originally published here

This will be the first blog post in a series of articles that I will do on this topic 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 from a specific assembly?
  • 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

The today blog post will be about: How can we easily export a binding file from a BizTalk Application?

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 bindings you want to export, 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 all bindings from the current application is selected, and then click OK

But even in 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.

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. If you know what you are doing, you can fix them directly on the environment after you import the Binding
  • 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 securities best practices you shouldn’t use the same BizTalk Groups in different environments, so in this case, if you follow this best practices, you need 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 do to improve this experience? And the response is that yes, all of this can be fully automated by using, for example, PowerShell scripts.

Again, I could fully automate this Binding generation for each environment, but let’s keep it simple and address what is mandatory and easily forgotten. In this sample let’s see how 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-application-exportbindings([string]$bindingFilePath, [string]$appName, [boolean]$generateDiffEnvBindings)
{
    $taskParams = ” ExportBindings /Destination:$bindingfilePath$appName.BindingInfo.xml /ApplicationName:$appName ”
    #First version: $p = [diagnostics.process]::start(“BTSTask.exe”, $taskParams)
    Start-Process "BTSTask.exe" $taskParams -Wait

    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")
    }
}

bts-application-exportbindings 'C:tempBTS' 'BizTalk Application 1' $True

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

You can download the full script from here: Export BizTalk Server Application Bindings with PowerShell

The post BizTalk Bindings Exportation: How to Export BizTalk Server Application Bindings with PowerShell appeared first on BizTalk360.