Using BTDF to create alternative ports for different environments

As you may know, the BizTalk Deployment Framework can help you use different settings for different environments. However, you can also easily use it to have completely different ports in different environments. So for example, if you have use a webservice in your test and production environment, but want to use file locations in your development environment, this can be easily done.
Start by making sure you have the following lines in your .btdfproj file inside of the first PropertyGroup:

<RequireXmlPreprocessDirectives>true</RequireXmlPreprocessDirectives>
<FilesToXmlPreprocess>Portbindings.xml</FilesToXmlPreprocess>

Next, in your SettingsFileGenerator.xml, add a property Environment, and set it’s values for your various environments, as following:
EnvironmentSettings
Here we have a default setting, Development, and separate settings for Test and Production.
Now switch to your PortBindingsMaster.xml, and add the various ports and receive locations you want for your different environments. Enclose the ports as following:

<!-- #if GetProperty("Environment")=="DEV" -->
<SendPort Name="Work on user" IsStatic="true" IsTwoWay="true" BindingOption="0">
.
. 
<SendHandler Name="${SendHost}" HostTrusted="false">
<TransportType Name="FILE" Capabilities="11" ConfigurationClsid="5e49e3a6-b4fc-4077-b44c-22f34a242fdb" />
</SendHandler>
.
.
<!-- #endif -->
<!-- #if GetProperty("Environment")=="TEST" -->
<SendPort Name="Work on user" IsStatic="true" IsTwoWay="true" BindingOption="0">
.
. 
<SendHandler Name="${SendHost}" HostTrusted="false">
<TransportType Name="WCF-BasicHttp" Capabilities="899" ConfigurationClsid="467c1a52-373f-4f09-9008-27af6b985f14" />
</SendHandler>
.
.
<!-- #endif -->

One thing to note, since we have defined RequireXmlPreprocessDirectives, is that we need to enclose all other placeholders as well, for example as following:

<!-- #ifdef _xml_preprocess -->
<Tracking>${TrackingSendPort}</Tracking>
<!-- #endif -->

3 thoughts on “Using BTDF to create alternative ports for different environments

  1. Pingback: Scott Banwart's Blog › Distributed Weekly 197

Leave a Reply

Your email address will not be published. Required fields are marked *