How to bounce a list of BizTalk host instances

Topics: Bindings File, Settings Management and SSO
Nov 8, 2011 at 9:35 PM

Hi Thomas,

Can you indicate how to specify the list of hosts from the environment settings file? The following does not seem to work:

  <ItemGroup>
    <PropsFromEnvSettings Include="HostList" />
  </ItemGroup>

  <ItemGroup>
    <BizTalkHosts Include="$(HostList)"/>
  </ItemGroup>

When attempting to deploy with these settings, the HostsList variable variable seems set, but not available to the BizTalkHosts item group:

[...]
SetPropertiesFromEnvironmentSettings:
  Setting properties from environment settings file (C:\[...]\Deployment\EnvironmentSettings\Exported_LocalSettings.xml)
  Setting property to value 'LowRcvHost;LowSndHost'.
[...]
BounceAllBizTalkHosts:
  Host list (BizTalkHosts ItemGroup) not customized.
  "C:\Program Files (x86)\Deployment Framework for BizTalk\5.0\Framework\DeployTools\cscript64.exe" /nologo "C:\Program Files (x86)\Deployment Framework for BizTalk\5.0\Framework\DeployTools\BounceBizTalkHost.vbs" ALL
  Stopping and starting: BizTalkServerApplication on DEVSTN3
  Stopping and starting: BizTalkServerApplication32 on DEVSTN3
  Stopping and starting: LowRcvHost on DEVSTN3
  Stopping and starting: LowSndHost on DEVSTN3
Done Building Project "C:\[...]\Deployment\Deployment.btdfproj" (Deploy target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:48.46

Thank you,

Nkishi.

Coordinator
Nov 10, 2011 at 6:41 AM

It's because of the order of evaluation in MSBuild.  The BizTalkHosts ItemGroup has already been parsed and evaluated long before the property is dynamically created from HostList.

There are two options here.  One is to use conditional ItemGroup's to define BizTalkHosts -- add a Condition attribute to the ItemGroup and use multiple ItemGroups.  You can use Condition="'$(Configuration)' = 'Server'", for instance, to define the ItemGroup that takes effect for a server deployment.  You can also use Condition="'$(COMPUTERNAME)' = 'MYSERVER'" because MSBuild picks up all environment variables as properties.

If that isn't flexible enough, then you'd need to redefine BizTalkHosts after the HostList property is assigned but before BizTalkHosts is used.  Unfortunately, the two related MSBuild targets execute 1-2 with no way to jump in between them (SetPropertiesFromEnvironmentSettings and ConditionalHostStop).

If HostList was defined as an environment variable or passed directly into MSBuild, it would also be defined early enough.

If you're using BizTalk 2009 or newer, there might be some other MSBuild 3.5+ ways to approach it.  Everything is currently targeted at MSBuild 2.0 to support back to BizTalk 2004.

Also, I remember that there have been one or two other MSBuild order of evaluation questions posted here in Discussions in the past.

Thanks,
Tom

Dec 9, 2012 at 12:37 AM
Edited Dec 9, 2012 at 12:37 AM

 

 Is there a way to check for a condition based on the settings that were chose? I would not want to restart any hosts unless this was a produciton deployment. For example ... 

  <PropertyGroup Condition="'$(????)' != 'Production_Settings'">
    <SkipHostInstancesRestart>false</SkipHostInstancesRestart>
  </PropertyGroup>
  <PropertyGroup Condition="'$(????)' == 'Production_Settings'">
    <SkipHostInstancesRestart>true</SkipHostInstancesRestart>
  </PropertyGroup>

  <ItemGroup Condition="'$(????)' == 'Production_Settings'">
    <BizTalkHosts Include="BizTalkReceive64_App1"></BizTalkHosts>
    <BizTalkHosts Include="BizTalkOrchestration64_App1"></BizTalkHosts>
    <BizTalkHosts Include="BizTalkSend64_App1"></BizTalkHosts>
  </ItemGroup>

Coordinator
Dec 9, 2012 at 6:16 AM

Add a setting (row) to your SettingsFileGenerator.xml Excel spreadsheet named (for example) CurrentEnvironment and enter the appropriate value for each environment column.  In your .btdfproj, add CurrentEnvironment to the semicolon-delimited list in the PropsFromEnvSettings ItemGroup (add if you don't have it).  Replace '$(????)' with '$(CurrentEnvironment)'.

Thanks,
Tom

Feb 27, 2014 at 1:14 PM
Hi Tom.

I have tried this approach and $(CurrentEnvironment) always returns an empty string. My main goal was to enter Host names into SettingsFileGenerator.xml Excel spreadsheet and to restart only selected host instances for different environments.

Code sample bellow returns an empty string for OrchestrationHost, SendHost, ReceiveHost, CurrentEnvironment

<ItemGroup>
<PropsFromEnvSettings Include="SsoAppUserGroup;SsoAppAdminGroup;OrchestrationHost;SendHost;ReceiveHost;CurrentEnvironment" />
</ItemGroup>

<PropertyGroup Condition="'$(CurrentEnvironment)' != 'Production_Settings'">
<SkipHostInstancesRestart>false</SkipHostInstancesRestart>
</PropertyGroup>
<PropertyGroup Condition="'$(CurrentEnvironment)' == 'Production_Settings'">
<SkipHostInstancesRestart>true</SkipHostInstancesRestart>
</PropertyGroup>

<ItemGroup Condition="'$(CurrentEnvironment)' == 'Production_Settings'">
<BizTalkHosts Include="$(OrchestrationHost)"></BizTalkHosts>
<BizTalkHosts Include="$(SendHost)"></BizTalkHosts>
<BizTalkHosts Include="$(ReceiveHost)"></BizTalkHosts>
</ItemGroup>

I assume that it has to do something with MSBuild order of execution, but i cannot figure it out.

Thanks

Milan
Coordinator
Feb 27, 2014 at 9:22 PM
Edited May 29, 2014 at 6:04 AM
Hi Milan,

It's still the order of evaluation issue. The PropertyGroup and ItemGroup have already been evaluated by the time the properties are created from the settings spreadsheet.

Assuming that you're on BizTalk 2010 or 2013... try this:
<ItemGroup>
  <PropsFromEnvSettings Include="SsoAppUserGroup;SsoAppAdminGroup;OrchestrationHost;SendHost;ReceiveHost;CurrentEnvironment" />
</ItemGroup>

<Target Name="PostPropsFromEnvSettings" AfterTargets="SetPropertiesFromEnvironmentSettings">
  <CreateProperty Value="false" Condition="'$(CurrentEnvironment)' != 'Production_Settings'">
    <Output TaskParameter="Value" PropertyName="SkipHostInstancesRestart" />
  </CreateProperty>
  <CreateProperty Value="true" Condition="'$(CurrentEnvironment)' == 'Production_Settings'">
    <Output TaskParameter="Value" PropertyName="SkipHostInstancesRestart" />
  </CreateProperty>
  <CreateItem Include="$(OrchestrationHost);$(SendHost);$(ReceiveHost)" Condition="'$(CurrentEnvironment)' == 'Production_Settings'">
    <Output TaskParameter="Include" ItemName="BizTalkHosts" />
  </CreateItem>
</Target>
Thanks,
Tom
Marked as answer by tfabraham on 2/28/2014 at 7:51 AM
Feb 28, 2014 at 11:21 AM
Thanks a lot Tom ! It works !
Coordinator
Feb 28, 2014 at 3:57 PM
OK, great! I've debated moving the SetPropertiesFromEnvironmentSettings step very early in the process and then internally restarting the script using the MSBuild task, which, in theory, should make this "just work" without the extra complication. Haven't had time to try it though.

Thanks,
Tom
Coordinator
Mar 3, 2014 at 6:45 PM
FYI, I've implemented a transparent fix for this issue in v6.0 that enables the normal MSBuild syntax as in your original example, with no workaround necessary.

Tom
Mar 3, 2014 at 8:49 PM
That's great news Tom ! Keep up with good work !