Search code examples
biztalkbiztalk-2013biztalk-deploymentbiztalk-rule-enginebtdf

BizTalk Deployment and Business Rules


I am a newbie to BizTalk development, having only been using it properly for 6-7 weeks, so forgive my naivety.

I have a basic BizTalk 2013 application in development and am ready to deploy to a test environment.

I am using business rules to define the Outbound Transport Location, after all transform have been done, this sends the data to a stored procedure in SQL Server, which inserts/updates the record:

mssql://.//db1?

When we deploy to our test/live environments, we will not be able to set the Outbound Transport Location to the local machine as the databases will be stored on separate servers to the application. For example:

mssql://dbserver//db1?

I have looked through the BizTalk Deployment Framework to see if business rules can be modified depending on environment, but couldn't find anything.

So my question is, what is the best (lowest maintenance) way to manage environment based settings for business rules? Using the BizTalk Deployment Framework would be preferable.


Solution

  • I'll post the solution I used for future reference and to help anyone who comes across this in the future.

    In the BizTalk Deployment Framework, it is possible to add additional XML files to the build, and pre-process them in the same way binding files are pre-processed depending on environment.

    Below are some snippets from the deployment.btdfproj file. Don't forget that with the BizTalk Deployment Framework, order is essential:

    <!-- Add the policy file as an additional item to the build -->
    <ItemGroup>
        <AdditionalFiles Include="my_policy_file.xml">
          <LocationPath>..\$(ProjectName)\location_to_policy</LocationPath>
        </AdditionalFiles>
    </ItemGroup>
    
    <!-- Processes the additional XML policy files added to the MSI main build folder. -->
    <ItemGroup>
        <FilesToXmlPreprocess Include="my_policy_file.xml">
             <LocationPath>..\</LocationPath>
        </FilesToXmlPreprocess>
    </ItemGroup>
    
    <!-- You still have to add the business rule to the build. It is overwritten later. -->
    <ItemGroup>
        <RulePolicies Include="my_policy_file.xml">
            <LocationPath>..\$(ProjectName)\location_to_property</LocationPath>
        </RulePolicies>
    </ItemGroup>
    
    <!-- Towards the end of the file the pre-processed file overwrites the originally included policy file. -->
    <Target Name="CopyXMLPreprocessedPoliciesToBRE" AfterTargets="PreprocessFiles">
        <copy sourceFiles="..\my_policy_file.xml" DestinationFolder="..\BRE\Policies"/>
    </Target>
    

    For more information, check out this thread on the BizTalk Deployment Framework site: https://biztalkdeployment.codeplex.com/discussions/392801