Using Configuration in BizTalk Map

Sorry for delay guys, I am coming with remaining pipeline articles very soon. Meanwhile, here is an interesting and useful thing to share.

During BizTalk map definition, sometime you might require to read some configuration value. For example, during use of database related functoids, you have to make connection string configurable. You can use BizTalk config file and scripting functoid to handle such scenario.

 Here is what you need to do -

1. Open "BTSNTSvc.exe.config" file from "drive:\Program Files\Microsoft BizTalk Server 2006 ".

2. Add configuration setting there such as -

<appSettings>

     <add key="CONNSTR" value="Data Source=SQL-SERVER;Initial Catalog=SAMPLE_DB;Integrated Security=SSPI"/>

</appSettings>

3. In map file, drag and drop script functoid and write following inline c# script.

   public string GetConnectionString()
{
string connString=System.Configuration.ConfigurationSettings.AppSettings.Get("CONNSTR").ToString();
return connString;
}

4. While using any database related functoid, drag output of script functoid as input in database functoid. And do not forget to put it in correct parameter sequence.

That’s it.

One more last thing, you cannot test config value in map at design time because configuration values are read BTS host at runtime.