Share via


Azure Logic Apps: Basic Transformation - Hello World

Important Note:

This article is currently out of date. The BizTalk Connectors referred to in this article are the older v1 connectors which are no longer visible in the new v2 Logic Apps Designer. Although you can still follow the steps to provision them (as per this document) you will not see those connectors appear in the new designer.

When the BizTalk connectors are released as v2 (managed) connectors (as part of the Enterprise Integration Pack later in 2016) this article will be updated to reflect this.

In the meantime, you can still access the v1 connectors created in this article by following the steps here: 

https://blogs.msdn.microsoft.com/logicapps/2016/02/25/accessing-v1-apis-and-biztalk-apis-from-logic-apps/

Introduction

This article  provides information on how to create Azure logic app for xml transformation.

This app will pick up the source xml from on premise directory, convert xml to another format and put that xml into another on premise directory.

For me that was the first step, but in a real BizTalk scenario there at least has to be one map! My scenario is to read from my local laptop 'inbox' folder, transform the message and write to the same laptop to an 'output' folder.

Components Required

Below are the software and components for creating the Sample

  • Visual Studio 2012.
  • Windows Azure BizTalk Services SDK
  • Azure Subscription.

Step by Step

  • Create Service Bus namespace on Azure portal.
  • Create and configure File connector API to connect local on premise directory with Azure.
  • Create Schema and Map required to transform XML format.
  • Create BizTalk Transformation API and upload created map in API
  • Test Azure Logical Transformation App.

Create ServiceBus namespace

We need to create Azure Service Bus namespaces, since it's required for configuring file connector. File connector under the hood uses the Service Bus Relay technology to connect to the on premise environment.

Service Bus namespace can be created from the old portal.

You can copy the connection string of the service bus from the connection information, which is required for configuring the File connector.

Create and Configure File connector for Directory

Create File Connector to connect with on premise local directory.

Goto Marketplace->Api Apps->File Connector.

  • Name: SharedDriveAFileConnector.
  • Roor Folder: D:\Azure\ShareDriveA

Service Bus Connection String: copied from the Service bus connection information.

Once you click the create button, it will take about a minute to provision the File connector (API App), before you can use it in your solution (Azure Logic App). You need to repeat the above steps to configure the second File connector to the destination location,

Goto Marketplace->Api Apps->File Connector.

  • Name: SharedDriveBFileConnector.
  • Root Folder: D:\Azure\ShareDriveB

Service Bus Connection String: copied from the Service bus connection information.

As you can notice there is a warning sign in the blade showing "Hybrid Connection - On Premise Setup Incomplete", just click on that box, which will open up "Hybrid Connection" blade. You will see a link labelled ON-PREMISES HYBRID CONNECTION MANAGER "Download and configure", clicking on that will download the on-premise agent file. Copy that file to the server where you'll have your folder location, and start installing it (internet connection is required of course), the installer will ask for service bus relay connection string as shown below

Once you provide that information and completed the installation procedure, leave few seconds and check back on the File Connector blade, it should now show the connection successfully established as shown below.

Create BizTalk Transformation API

We have to transform one XML to another so we will use BizTalk Transform API and use into our logic app.

Again go to the Azure Marketplace, search for "BizTalk Transform service" and create a new instance. Steps for creating the BizTalk Transform service is straight forward and doesn't need any hybrid connection step up.

once API is created we can add map into the service

Create BizTalk Schema and Map

Create the BizTalk Schema and Map in Visual Studio 2012.

  • Create Input Schema

  •   Create Output Schema

  • Create Map for transformation

  • Upload Map into the BizTalk Transformation Service APP.

Create Azure Logic App

Goto Azure portal

  • New-> Logic Apps->Logic App->

  • Name: AzureTransformationApp
  • Click on Trigger and Action

  • Configure BizTalk Transformation Service.
  • Configure File Connector.

Test the Application

  1. Drop the input file at source location.
  2. Check the target location

Input



            <      p      ><      ns0:PO             xmlns:ns0      =      "              http://HelloWorld.POSchema            "      ></      p      >      
            <      p      ><      font      >  </      font      ><      PO_Number      >PO_Number</      PO_Number      ></      p      >      
            <      p      ><      font      >  </      font      ><      Total      >10</      Total      ></      p      >      
            <      p      ></      ns0:PO      ></      p      >      

Output:



            <      p      ><?      xml             version      =      "1.0"             encoding      =      "utf-8"      ?></      p      >      
            <      p      ><      ns1:Invoice             xmlns:ns0      =      "              http://HelloWorld.POSchema            "             xmlns:ns1      =      "              http://HelloWorld.InvoiceSchema            "      ></      p      >      
            <      p      ><      font      >  </      font      ><      Number      >PO_Number</      Number      ></      p      >      
            <      p      ><      font      >  </      font      ><      TotalPrice      >10</      TotalPrice      ></      p      >      
            <      p      ></      ns1:Invoice      ></      p      >      

You can check the status of runs from the dashboard.

Possible Error

How to Check Errors in Azure Logic Apps:

Go to Logic App.

  • Click on Trigger History

Error "duplicate collection entry":

Error Statement: Cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'fileExtension' set to '.json'

Solution: Remove the mimeMap tag from IIS service which was created for File Connector

<p> </p>
<p><staticContent></p>
<p><font>      </font><mimeMap fileExtension=".json" mimeType="application/json" /></p>
<p><font>    </font></staticContent></p>
<p> </p>

Error "Access Denied"

Check access of folder location.

Source Code

You can download full document from MSDN gallery

Other languages

See Also

Another important place to find a huge amount of Logic Apps related articles is the TechNet Wiki itself. The best entry point is Microsoft Azure App Service Resources on the TechNet Wiki.