Automated testing of Azure Biztalk Services maps

March 4, 2016 LeandroDG No comments

Azure BizTalk Services (also known as WABS: Windows Azure Biztalk Services and MABS: Microsoft Azure Biztalk Services) enables Biztalk-like services that run on the cloud.

Like BizTalk Server, Azure BizTalk Services include a mapping/transform services is included. This service can be invoked to perform XML mapping in Azure Logic Apps.

Unlike regular BizTalk, there’s nothing included in the SDK to perform automated map testing.

After playing around with Reflection and the Visual Studio Extension assemblies included in the Biztalk Services SDK, we are now able to programatically test Biztalk Services maps (maps with trfm extension).

I created a simple helper class that can be used to test the map.

All you need to do is call the static MapTester.TestMap method with the map file path and the input file path. Here’s a sample test call:

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BizTalkServicesTesting.Helpers;
using System.IO;

namespace BizTalkServicesTesting.Tests
    public class MapUnitTests
        public void SampleMapTest()
            var mapFilePath = @"..\..\..\BiztalkServicesTesting.Artifacts\Map.trfm";
            var inputFilePath = @"SampleInput.xml";
            var testMapResult = MapTester.TestMap(mapFilePath, inputFilePath);

            Assert.AreEqual(true, testMapResult.Success);
@"<?xml version=""1.0"" encoding=""utf-8""?>
<ns1:Root xmlns:ns0="""" xmlns:ns1="""">
</ns1:Root>", testMapResult.OutputText);

In order to be able to use this library, we need to reference several Azure BizTalk Services SDK assemblies. To avoid licensing issues I haven’t provided included them in the post, you can download the SDK from here:

These are the libraries you need to add them to the Lib folder in the downloaded source code, or add as references in your unit test projects if you download the compiled version. Once the SDK is installed, they can be found in the following path “C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Windows Azure BizTalk Services SDK”.

  • Microsoft.ApplicationServer.Integration.Common.Core.dll
  • Microsoft.ApplicationServer.Integration.Common.dll
  • Microsoft.ApplicationServer.Integration.Pipeline.dll
  • Microsoft.ApplicationServer.Integration.Services.Pipeline.Tracing.dll
  • Microsoft.ApplicationServer.Integration.Transforms.BaseFunctoids.dll
  • Microsoft.ApplicationServer.Integration.Transforms.Common.dll
  • Microsoft.ApplicationServer.Integration.Transforms.Compiler.Common.dll
  • Microsoft.ApplicationServer.Integration.Transforms.Compiler.XamlGenerator.dll
  • Microsoft.ApplicationServer.Integration.Transforms.MapCompiler.dll
  • Microsoft.ApplicationServer.Integration.Transforms.MapOM.dll
  • Microsoft.ApplicationServer.Integration.Transforms.Mapper.OM.dll
  • Microsoft.ApplicationServer.Integration.Transforms.Runtime.BuiltInFunctions.dll
  • Microsoft.ApplicationServer.Integration.Transforms.Runtime.dll
  • Microsoft.ApplicationServer.Integration.Transforms.TOM.dll

This is how it works:

// Create output temp file name
var outputFilePath = Path.GetTempFileName();

// Get MapCompiler type and methods
var mapCompilerType = Type.GetType("Microsoft.ApplicationServer.Integration.Transforms.MapCompiler.MapCompiler, Microsoft.ApplicationServer.Integration.Transforms.MapCompiler");
var mapCompilerTestMapMethod = mapCompilerType.GetMethod("TestMap");

// Get TestMapConfiguration type and create instance
var testMapConfigurationType = Type.GetType("Microsoft.ApplicationServer.Integration.Transforms.MapCompiler.TestMapConfiguration, Microsoft.ApplicationServer.Integration.Transforms.MapCompiler");
var testMapConfigurationInstance = testMapConfigurationType.GetConstructor(new Type[] { typeof(Dictionary<String, Object>) }).Invoke(new object[] { new Dictionary<String, Object>() });

// Get TestMapResult type and properties
var testMapResultType = Type.GetType("Microsoft.ApplicationServer.Integration.Transforms.MapCompiler.TestMapResult, Microsoft.ApplicationServer.Integration.Transforms.MapCompiler");
var testMapResultOutputFileWrittenProperty = testMapResultType.GetProperty("OutputFileWritten");
var testMapResultErrorsProperty = testMapResultType.GetProperty("Errors");
var testMapResultWarningsProperty = testMapResultType.GetProperty("Warnings");

// Get MapError type and properties
var mapErrorType = Type.GetType("Microsoft.ApplicationServer.Integration.Transforms.Common.MapError, Microsoft.ApplicationServer.Integration.Transforms.Common");
var mapErrorErrorMessageProperty = mapErrorType.GetProperty("ErrorMessage");

// Invoke MapCompiler TestMap method
dynamic testMapResult = mapCompilerTestMapMethod.Invoke(null, new object[] { mapFilePath, inputFilePath, outputFilePath, testMapConfigurationInstance });

// Process TestMap results
var result = new ExecutionResult();
result.Errors = ((IEnumerable<dynamic>)testMapResultErrorsProperty.GetValue(testMapResult)).Select(e => mapErrorErrorMessageProperty.GetValue(e)).Cast<string>().ToArray();
result.Warnings = ((IEnumerable<dynamic>)testMapResultWarningsProperty.GetValue(testMapResult)).Select(e => mapErrorErrorMessageProperty.GetValue(e)).Cast<string>().ToArray();
var outputMessageWritten = (bool)testMapResultOutputFileWrittenProperty.GetValue(testMapResult);

if (outputMessageWritten)
    result.OutputText = File.ReadAllText(outputFilePath);

    if (result.Errors.Length == 0)
        result.Success = true;

BizTalk Services Testing Source Code (79)
BizTalk Services Testing Binaries (63)

VN:F [1.9.11_1134]
Rating: 5.0/5 (2 votes cast)

Import BizTalk binding file sets incorrect pipeline

February 13, 2013 adglopez No comments

I thought would be better to show rather explain so there you go


VN:F [1.9.11_1134]
Rating: 5.0/5 (1 vote cast)
Categories: Uncategorized Tags:

Materiales del CodeCamp BA 2011 – Datos en la nube (Azure) y Business Intelligence (PowerPivot)

October 21, 2011 adglopez and LeandroDG No comments

Hola a todos, les dejamos disponible los materiales de las charlas del codecamp que estuvimos dando Leandro y yo (Adrian)

- Haciendo BI rápido y flexible
- Datos en la nube: colas, caché, topics y otras yerbas

Descarga de los materiales:
- Haciendo BI rápido y flexible (263)
- Datos en la nube: colas, caché, topics y otras yerbas (390)

VN:F [1.9.11_1134]
Rating: 5.0/5 (2 votes cast)

Using Azure AppFabric Labs without servicebus.config

October 13, 2011 LeandroDG No comments

Azure has been offering a preview of possible future features for a long time now. SQL Azure has SQLAzureLabs (, and AppFabric has AppFabricLabs (

You download the latest SDK CTP for AppFabric Labs, you create an AppFabric Labs account at their portal and you can work with it inmediately… well… almost!

There’s an issue regarding the service URL, you don’t need to assign the AppFabric Services URL for it to work with production Azure AppFabric, but to work with Labs you are forced to specify it. Some information about it is available here:

It requires modifying (or creating a new one) ServiceBus.config file and drop it into your .NET Framework config directory. The problem with this approach is that it forces you to use labs in ALL your Azure AppFabric applications. And you may want to use both Labs and Production Azure AppFabric at the same time. As it says in that post, if you try to change the URL manually, you end up in this error:

AppFabric ServiceBus Error: “can’t support more than 1 level subdomain”

I read that another possibility is setting environment variables for this, so there’s an even easier way and you don’t have to go through all the config directories, which can create confusion. And when you are done with labs, you will probably run into an issue when trying to run in Azure Production environment, when you forget to delete the ServiceBus.config configuration.

So, the easy way is to put this at the beginning of your application, service, website (in global.asax), etc.:

   Environment.SetEnvironmentVariable("RELAYENV", "Custom");
   Environment.SetEnvironmentVariable("RELAYHOST", "");
   Environment.SetEnvironmentVariable("STSHOST", "");
VN:F [1.9.11_1134]
Rating: 5.0/5 (1 vote cast)

Tellago Technology Updates

May 4, 2011 adglopez and LeandroDG No comments
Tellago announces the new technology webinar series!
The idea is to help organizations to be more effective in their decisions about strategies and evaluations adopting technologies, to achieve this, will be doing  monthly a series of webinars oriented to decision makers, developers and IT professionals.
These will be presented by some of our experts in the different areas and trying to make this as much interactive as possible, for more info you can follow this link.
VN:F [1.9.11_1134]
Rating: 5.0/5 (1 vote cast)
Categories: Uncategorized Tags: , , , ,