Friday 29 June 2007

Automate deployment of Business Rules



You must be tired of using biztalk business rules engine deployment wizard to export and import policies and vocabularies. For eg. if you have 40 business rules and 20 vocabs defined in business rule composer, you need to run the wizard again and again to export to an xml and import from an xml. It becomes painful to run the wizard. The code in the images helps you to do the same without using the wizard. All you need to do is to create a batch file and invoke an exe created by putting the following in a console application. The following code shows how to export the policies and vocabs to an xml file.
Once you have exported to an xml file, you will need to import them to another machine or even again on your own machine. The second image shows how to import the policies and vocabs to any machine by running the exe through a batch file. These two code pieces can be used for even deleting the policies and vocabs. They publish the vocabs and deploy the policies too. The following sample shows the contents of the batch file used to run these console applications. The calls can be used in a sequence in a single file.

The below sample is for importing the policies and vocabs from xml:

REM *** Call ApplicationName Policy/VocabularyName FileLocation

REM *** Delete Policies
call ImportBRE " " " " "CustomerPolicy"

REM *** Import Vocabularies
call ImportBRE "CommonField" "..\vocabulary files\CommonField-1.0.xml" "CommonField"

REM *** Import Policies
call ImportBRE "CustomerPolicy" "..\policy files\CustomerPolicy.xml" "1"

The below sample is for exporting the policies and vocabs:

REM *** Call ApplicationName Policy/VocabularyName MajorRevision MinorRevision
REM *** Export Vocabularies

call ExportBRE "CommonField" "1" "0"

REM *** Export Policies
call ExportBRE "CustomerPolicy" "1" "0"

No comments: