Server Deployment when BAM definitions mismatch

Topics: General Questions, Server Deployment, Tips and Tricks
Jun 20, 2011 at 2:24 PM

Hi Tom,

This thread is for seeking advise for a Biztalk application deployment scenario when the BAM Definition don't match with the one that is already deployed.
This discussion is an extension to your discussions in thread : http://biztalkdeployment.codeplex.com/discussions/252839


Scenario 1 (Undeploy, Uninstall BizTalkApplication followed by Deployment of BizTalkApplication of same version)

1. Undeploy MyBizTalkApplication Version 1.0 (BAM definitions are not removed by default as security feature)
2. Uninstall  MyBizTalkApplication Version 1.0 (MyBizTalkApplication.BAMDefinition_LastAutoDeploy.xml is kept in ProgramFiles\MyBizTalkApplication\1.0\BAM\ folder)
3. Install MyBizTalkApplication Version 1.0 ( This time the Msi contains changed BAM definition)
4. Deploy MyBizTalkApplication Version 1.0 

Result
Deployment halted due to mismatch between the updated BAM definition and the MyBizTalkApplication.BAMDefinition_LastAutoDeploy.xml)


Scenario 2 (Undeploy, Uninstall BizTalkApplication followed by Deployment of BizTalkApplication with new version)

1. Undeploy MyBizTalkApplication Version 1.0 (BAM definitions are not removed by default as security feature)
2. Uninstall  MyBizTalkApplication Version 1.0 (MyBizTalkApplication.BAMDefinition_LastAutoDeploy.xml is kept in ProgramFiles\MyBizTalkApplication\1.0\BAM\ folder)
3. Install MyBizTalkApplication Version 2.0 ( This time the Msi contains changed BAM definition and the files are extracted to ProgramFiles\MyBizTalkApplication\2.0 folder)
4. Deploy MyBizTalkApplication Version 2.0 

Result
Deployment failed due to some issue when trying to deploy the new BAM definition


In both the above scenarios, the BAM deployment is bound to fail as the BAM definitions differ (working as per design).
Currently I am removing the BAM definitions manually.

I would just like to know your opinion on what would be the best practise in such scenarios ?
I was planning to add a custom task (That would execute a SQL script to archive BAM data during every deployment) and add the tag <SkipBamUndeploy>false</SkipBamUndeploy> so that the definitions gets removed each time I undeploy the BizTalk Application.
But this solution seems to be very appealing one.

I was rather hoping that the redeployment in Server installation should remove older BAM defninitions and deploy the new ones, however it doesn't.
Please advise if we can have some similar workaround so that I don't have to remove BAM definitions manually in case the deployment fails due to BAM definitions.

Thanks,
Avinandan

 

Coordinator
Jun 23, 2011 at 4:27 AM

Hi Avinandan,

It really comes down to one question:  Do I need to preserve existing BAM data between deployments?

If the answer is "No," then all you need to do is set SkipBamDeploy to false in the existing <PropertyGroup Condition="'$(Configuration)' == 'Server'"> in your .btdfproj.  By default, it's false for local deployments and true for server deployments.  That's the safeguard to avoid inadvertently losing data when the answer to that question is "Yes."  If you set it to false all the time, then the server undeploy will remove the BAM definition and you won't have any issue with installing the updated version.

If the answer is "Yes" then things are quite difficult, as discussed in the thread that you referenced.  It would work to do as you suggested and use one of the extension Targets to run a SQL backup of the existing BAM data AND set SkipBamUndeploy to false.  Of course that leads to the question of whether it's important to re-load the data into the BAM databases after the new version is in place or just keep it in an archive.  Nothing is easy about this path.  The whole BAM subsystem is so poorly documented that it's very hard to figure out BAM model upgrade/update scenarios.

I was trying to guess at which way you would answer the question, and could not be certain from your message.  I'm hopeful that it's "No" so that you can take the easy path!

Thanks,
Tom

Jun 23, 2011 at 9:46 AM
Edited Jun 23, 2011 at 10:01 AM

Hi Tom,

My answer to your question is unfortunately "Yes".

For the above 2 scenarios, I have made a simple bat file (included in the MSI) that the release engg should execute in case the MSI Server deployment fails due to BAM definitions.

The Batch file would prompt the Release Engineer the location of the InstallationPath of the BizTalk Application that was last deployed (with which the old BAM definitions were deployed and the BAMdefinition_LastAutoDeploy.xml is present  ) say . The batch would then remove the BAMDefinition_LastAutoDeploy.xml using the usual bm.exe command.

Remove Older BAM Definitions Batch File Content:--

@ECHO ===START ==============
@ECHO OFF

SET /P LastInstallationDir=Please enter the Installation Directory of the BizTalk Application that was uninstalled previously : %=%

SET LastInstallationBAMDir=%LastInstallationDir%\BAM
CD %LastInstallationBAMDir%

@echo ==REMOVING OLDER BAM DEFINITIONS THAT ARE KEPT BY BTDF ==

for /f %%a IN ('dir /b *_LastAutoDeploy.xml') do call "%BTSINSTALLPATH%/Tracking/bm.exe" remove-all -DefinitionFile:%%a

@echo ==END =======
pause

Following this the Release Engg would proceed and 'Redeploy' the failed BizTalk Application by going to Start --> All Programs --> BizTalk Application --> Redeploy option.

Feature Request 1

However still leaves room for error by the Release Engineer. I was just wondering if a menu item could be added that could do just the part that above batch file is doing such that the Release Engineer wont have to search for this batch file in the installation path of the current BizTalk MSI and rather would just go to Start --> All Programs --> BizTalk Application (new Version) --> Deploy Old BAM Definitions.

Feature Request 2
Alternatively just add a menu item to Remove BAM Definitions ( Start --> All Programs --> BizTalk Application (Current Version) --> Remove Current BAM Definitions) such that the Release engineer would have the option to remove the BAM definitions even after the BizTalk Application is undeployed. This way we could instruct the Release engineer to use this option if a particular new release contains updated BAM Definitions.

Please advise.

Coordinator
Jul 8, 2011 at 5:06 AM

I tend to prefer the second option, a menu item to explictly undeploy the BAM model.  It's not something that I can implement for 5.0, but can consider in the future.  Would you mind adding a feature suggestion under the Issue Tracker so it doesn't get lost in the shuffle (and include a link back to here for reference)?

Thanks!
Tom