Build and deploy multiple BizTalk applications

Build definition

In typical BizTalk scenarios there are often many applications, and they must also be deployed in a specific order due to dependencies, and undeployed in the reverse order. This is a labor intensive and time-consuming process.
To speed things up we use PowerShell scripts to automate deployment and undeployment.

Build

In this case we want to build everything from the Test branch and create a deployment package that can be installed on the test environment.

Make sure all the build scripts are in place in then BuildScripts folder. Download the scripts from the source code section.

BuildScripts2.png

Open the “Applications.txt” file, and edit the list of applications. The name must match the <ProjectName> from the Deployment.btdfproj file. The applications will be deployed in the same order as in the list, and undeployed in the reverse order.

CreateDeployment.png

Check in the changes. Merge to the Test branch, and remember to check in the merge operation.
Now, create a new build definition to build everything from the Test branch. Since we want to build everything, it is OK to select the top-level folder in “Source Settings”.

MultiBuild1.png

Add all the solutions and deployment projects in the correct order.

MultiBuild2.png

For the Test branch, make a Release build, since we later want to test the same version of the code that will go into production.

MultiBuild3.png

If you have enabled unit testing for your BizTalk application, those tests will have to be disabled for Release builds. Also, make sure that the Release configuration for your solution does not built the unit test project.

MultiBuild4.png

Set the “CreateDeployment.ps1” script as the Post-build script. This script will create a ZIP file with everything needed for deployment.

MultiBuild5.png

Track your builds

If you deploy to multiple systems it is very useful to keep track of which build is installed where. One way to do that is to update the assembly file version. Then you can look at an assembly to figure out which build it was installed from. Include the "UpdateVersionInfo.ps1" script as a pre-build script to update the version info automatically on each build. The script sets the build ID as the revision number. It also updates the .btdfproj file with at new ProductID and puts the build name in a comment.

Version1.png

The highlighted fields in the btdfproj file are changed for each build.
Version2.png

Thanks to rlofthus for providing the versioning script.

Deployment

Start a new build. When the build is done, look in the drop folder. There is a ZIP file with the build name and number. Copy this file to the BizTalk servers and extract it.

MultiBuild6.png

Deploying BizTalk applications is a two-step process. First, the assemblies have to be installed on the servers, and second the configuration has to be imported into BizTalk. The first step happens on all servers in a BizTalk group. The second step is done only once. The deploy script uses an environment variable to determine what action to take.

In the system settings, on the BizTalk servers, add a new system environment variable: BTDF_DeployToBizTalk. Set this to “true” on one server and “false” on all the other server.

Deploy1.png

Add a second variable: BTDF_Env. This is used by the deploy script to select the right configuration from the settings Excel sheet. In this case, we want to use the settings for the Test environment. Make sure you have the same settings on all BizTalk servers in the group.

Deploy2.png

Create at folder on all BizTalk servers called “BizTalkDeploy”, copy the ZIP file from the dropfolder, and extract it. You should have a folder like this:

Deploy3.png

Start PowerShell as administrator. If you have not already done so, set the execution policy to unrestricted.
Change directory to where you extracted the files and run the Deploy.ps1 script.

Deploy4.png

When the script is done, repeat for all servers in the group.

Deploy5.png

If the deployment fails for some reason, check the DeployResults.txt file for errors. It is located in each applications install folder (C:\Program Files (x86)\Contoso.Calculator for BizTalk\1.0\DeployResults\DeployResults.txt).

Previous Next

Last edited Aug 6, 2014 at 1:15 PM by hallis, version 17