Updating BizTalk SSO DB using BTDF and a simple BTDF deployment

Introduction

In some cases, it becomes important to securely store key-value pairs, such as configuration data (e.g., usernames and passwords), rather than hardcoding them within a BizTalk orchestration. One effective way to achieve this is by storing these key-value pairs securely in the BizTalk SSO (Enterprise Single Sign-On) database and subsequently reading these values within our orchestration through a simple line of code within a BizTalk expression shape. In this blog post, we will go through the steps to add key-value pairs to the SSO database using the BizTalk Deployment Framework (BTDF). We will also explore how to read these values within a BizTalk orchestration and perform a simple BizTalk deployment using BTDF.

Steps

Creating a BizTalk Solution, Schema Project and Map project:

  • Let's first create a BizTalk Solution called "SSOPOC" and a project called "SSOPOC.Schema". For this, you need to go to Visual Studio and click on File --> New Project --> Empty BizTalk Server Project and name the project and the solution as defined above.
  • Create a new XML schema and name it SourceA

  • Create another XML schema and name it as "SourceB" schema


  • Add a new project in the solution and name it as "SSOPOC.Maps". Add a reference to the schema project "SSOPOC.Schema" under this project.
  • Right click on the project -->Add a new item --> BizTalk Project Items --> Map and name the map as 
  • "SourceA_To_SourceB.btm".
  • Perform the mapping as shown in the figure given below.




  • Configure the signing key and name the application name as "SSOPOC" for both the projects





Adding BizTalk Deployment Framework:

  • Right on the solution --> Add new Project --> Deployment Framework for BizTalk Project


  • Name it "Deployment"


  • Add a new solution folder and name it "Deployment". Right-click on the folder--> Add existing item --> Add the BTDF related files from the "Deployment" folder located in the file location. Please refer to the figure given below.





  • Edit the "Deployment.btdfproj" file as shown below

<?xml version="1.0" encoding="utf-8"?>
<!-- 
  Deployment Framework for BizTalk
  Copyright (C) Thomas F. Abraham, Scott Colestock
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Installer">
  <PropertyGroup>
    <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
    <Platform Condition="'$(Platform)' == ''">x86</Platform>
    <SchemaVersion>1.0</SchemaVersion>
    <ProjectName>SSOPOC</ProjectName>
    <ProjectVersion>1.0</ProjectVersion>
<IncludeSSO>False</IncludeSSO>
    <IncludeOrchestrations>False</IncludeOrchestrations>
<IncludeTransforms>True</IncludeTransforms>
    <UsingMasterBindings>True</UsingMasterBindings>
    <RequireXmlPreprocessDirectives>False</RequireXmlPreprocessDirectives>
    <ApplyXmlEscape>True</ApplyXmlEscape>
    <SkipIISReset>True</SkipIISReset>
    <SkipHostInstancesRestart>True</SkipHostInstancesRestart>
    <StartApplicationOnDeploy>False</StartApplicationOnDeploy>
    <EnableAllReceiveLocationsOnDeploy>False</EnableAllReceiveLocationsOnDeploy>
    <StartReferencedApplicationsOnDeploy>False</StartReferencedApplicationsOnDeploy>
    <SsoAppUserGroup Condition="'$(SsoAppUserGroup)' == ''">vipindomain\BizTalk Application Users</SsoAppUserGroup>
    <SsoAppAdminGroup Condition="'$(SsoAppAdminGroup)' == ''">vipindomain\BizTalk Server Administrators</SsoAppAdminGroup>
  </PropertyGroup>
  <PropertyGroup>
    <!-- Properties related to building an MSI for server deployments -->
    <!-- BizTalk App Version Upgrade -->
    <!--   For each new product release to be deployed to your BizTalk servers: -->
    <!--     1) Increment ProductVersion -->
    <!--     2) Generate a new GUID and update ProductId with the new GUID -->
    <!--   This allows the new MSI to automatically uninstall (not undeploy!) the old MSI and install the new one. -->
    <ProductVersion>1.0.0</ProductVersion>
    <ProductId>3a9260db-4a4c-4643-baa9-6bf58658a726</ProductId>
    <!-- BizTalk App Version Upgrade -->
    <ProductName>SSOPOC for BizTalk $(ProductVersion)</ProductName>
    <Manufacturer>Deployment Framework User</Manufacturer>
    <PackageDescription>SSOPOC</PackageDescription>
    <!-- NEVER change the ProductUpgradeCode. -->
    <ProductUpgradeCode>4e02aed3-774c-4d21-a6ad-49d168491254</ProductUpgradeCode>
  </PropertyGroup>
  <!-- Under TFS Team Build, set CustomizableOutDir property to true in TFS 2005/2008/2010 UpgradeTemplate. -->
  <!-- With a workflow build, copy the default template then modify the MSBuild task for the solution build. Set OutDir to blank and -->
  <!-- CommandLineArguments to String.Format("/p:SkipInvalidConfigurations=true;TeamBuildOutDir=""{0}"" {1}", BinariesDirectory, MSBuildArguments). -->
  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <DeploymentFrameworkTargetsPath>$(MSBuildExtensionsPath)\DeploymentFrameworkForBizTalk\5.0\</DeploymentFrameworkTargetsPath>
    <OutputPath Condition="'$(TeamBuildOutDir)' == ''">bin\Debug\</OutputPath>
    <OutputPath Condition="'$(TeamBuildOutDir)' != ''">$(TeamBuildOutDir)</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <DeploymentFrameworkTargetsPath>$(MSBuildExtensionsPath)\DeploymentFrameworkForBizTalk\5.0\</DeploymentFrameworkTargetsPath>
    <OutputPath Condition="'$(TeamBuildOutDir)' == ''">bin\Release\</OutputPath>
    <OutputPath Condition="'$(TeamBuildOutDir)' != ''">$(TeamBuildOutDir)</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Server'">
    <DeploymentFrameworkTargetsPath>Framework\</DeploymentFrameworkTargetsPath>
    <!-- Get our PDBs into the GAC so we get file/line number information in stack traces. -->
    <DeployPDBsToGac>false</DeployPDBsToGac>
  </PropertyGroup>
  <ItemGroup>
    <PropsFromEnvSettings Include="SsoAppUserGroup;SsoAppAdminGroup" />
  </ItemGroup>
  <!-- !!! TODO !!! -->
  <!-- Add ItemGroup elements that contain one or more Schemas, Orchestrations, Transforms, etc. elements that describe -->
  <!-- the specific artifacts in your solution that need to be deployed. Use IntelliSense as a guide. -->
  <ItemGroup>
    <Schemas Include="SSOPOC.Schema.dll">
      <LocationPath>..\SSOPOC.Schema\bin\$(Configuration)</LocationPath>
    </Schemas>
    <Transforms Include="SSOPOC.Maps.dll">
      <LocationPath>..\SSOPOC.Maps\bin\$(Configuration)</LocationPath>
    </Transforms>
  </ItemGroup>
  <!-- !!! TODO !!! -->
  <Import Project="$(DeploymentFrameworkTargetsPath)BizTalkDeploymentFramework.targets" />
  <!--
    The Deployment Framework automatically packages most files into the server install MSI.
    However, if there are special folders that you need to include in the MSI, you can
    copy them to the folder $(RedistDir) in the CustomRedist target.
    To include individual files, add an ItemGroup with AdditionalFiles elements.
  -->
  <Target Name="CustomRedist">
  </Target>
</Project>

  • We will first try to deploy the solution using normal BizTalk deployment. Right-click on the solution -->  Deploy Solution


  • In the admin console create the Receive ports, Receive location and Send port under the application "SSOPOC". Please refer to the figures given below.





  • Export the bindings
  • Copy the contents in the binding file and paste it into the "PortBindingsMaster.xml" file. Save the file.
  • Now that we have performed all the configuration steps, let us try to deploy the solution using the BTDF framework. Tools --> BizTalk Framework for BizTalk --> Deploy BizTalk Solution



  • You can see that the BTDF deployment is completed successfully.

Updating SSO DB using BTDF

  • Now let us try to understand how we can add values onto the SSO DB using BTDF deployment.
  • Go to the file location where the Deployment folder is located in our case "C:\Users\c-vJayanarayanan\source\repos\SSOPOC\Deployment"
  • Before following the next step, make sure that office 365 is installed on your dev server. If not you might not be able to edit the file using excel feature
  • Go to SettingsFileGenerator --> Open with --> Office XML handler



  • Add Values for SsoAppUserGroup and SsoAppAdminGroup


  • Add the key value pairs that you would like to insert onto the SSO DB
  • In our case the key is  "ID" and the value is "2049069".
  • Save the file
  • Modify the "Deployment.btdfproj" file to configure "IncludeSSO" as "True.
  • Go to Visual Studio --> Tools --> Deployment Framework for BizTalk --> Update SSO from Settings Spreadsheet


  • To validate whether the SSO key-value pairs have been successfully added to the SSO database, navigate to "C:\Program Files (x86)\Deployment Framework for BizTalk 5.8\Framework\DeployTools.
  • Right click on the "SSOSettingsEditor" application and click on Run as administrator. Under SSO Affiliate App Name type "SSOPOC" and click on "Load".



  • You can see that the SSO key value pairs were added onto the SSO DB





Reading SSO Values in an Orchestration

Now, let's explore how to read SSO values within a BizTalk orchestration

Prior to reading SSO values, ensure that you have successfully added these values to the SSO database using the BTDF deployment method, as detailed in the previous section
• In your orchestration, make sure to reference the "SSOSettingsFileReader.dll" assembly. Ideally, this DLL should reside in the Global Assembly Cache (GAC), assuming you've installed BTDF. Alternatively, you can locate it under "C:\Program Files(x86)\Deployment Framework for BizTalk 5.8\Framework\DeployTools.
• In an expression shape write the following code. Be sure to modify the parameters and variables to align with your specific requirements:

ID=SSOSettingsFileManager.SSOSettingsFileReader.ReadString("SSOPOC","ID");

  • This code helps in the retrieval of SSO values by invoking the ReadString method from the SSOSettingsFileReader class. It contains two arguments:
  • Application Name ("SSOPOC"): This parameter designates the SSO application from which to retrieve the data.
  • Key Name ("ID"): The key identifier specifying the exact value you intend to retrieve.











Comments

Popular posts from this blog

Error: Number of included segments do not match

REST API Calls with Query Parameters in BizTalk: A Step-by-Step Guide

Document flow in Boomi