0

Harnessing the Power of Logic App Data Mapper in Visual Studio Code

In the realm of cloud computing and integration, efficiency and clarity in data transformation are paramount. Azure Logic Apps provides a robust platform for automating workflows and integrating apps, data, systems, and services across enterprises. A pivotal feature within this suite is the Logic App Data Mapper, especially when utilized within Visual Studio Code (VS Code). This article aims to elucidate the process of leveraging the Data Mapper in VS Code, enhancing your data transformation tasks with ease and precision.

Prerequisites

Before diving into the Data Mapper, ensure that you have the following prerequisites in place:

  • Visual Studio Code installed on a Windows operating system.
  • The Azure Logic Apps (Standard) extension installed in VS Code. This extension now includes the previously separate Data Mapper extension, streamlining the user experience.

Steps:

The Data Mapper tool in VS Code simplifies the creation of maps for data transformation. Here’s how to get started:

  1. Initiate a New Logic App Project: Begin by setting up a new project within VS Code, selecting the appropriate workflow type and defining your project’s structure.
  2. Access the Data Mapper: Within your project, navigate to the Data Mapper tool. This can be found integrated within the Azure Logic Apps (Standard) extension.
  3. Define Source and Target Schemas: Select the XML or JSON files that represent the data types you wish to transform. The Data Mapper allows for XML to XML, JSON to JSON, XML to JSON, and JSON to XML transformations.
  4. Map Your Data: Utilize the drag-and-drop interface to create mappings between your source and target schemas. The tool provides a library of prebuilt functions to aid in creating expressions for your data map.
  5. Save and Test Your Map: Once your mappings are in place, save your map and test it with sample messages to ensure accuracy.
  6. Integrate with Your Workflow: After testing, integrate your map directly into your Logic App workflow, either within VS Code or deployed to Azure.

Creating a data map

  1. On the Visual Studio Code left menu, select the Azure icon.
  2. In the Azure pane, under the Data Mapper section, select Create new data map.Screenshot showing Visual Studio Code with Data Mapper tool, Azure window open, and selected button for Create new data map.
  3. Provide a name for your data map.
  4. Specify your source and target schemas by following these steps:
    1. On the map surface, select Add a source schema.Screenshot showing Visual Studio Code with Data Mapper open, new data map, and selected option for Add a source schema.
    2. On the Configure pane that opens, select Add new > Browse.
    3. Find and select your source schema file, and then select Add.If your source schema doesn’t appear in the Open window, from the file type list, change XSD File (*.xsd) to All Files (*.*).The map surface now shows the data types from the source schema. For the examples in this guide,
    4. On the map surface, select Add a target schema.
    5. On the Configure pane that opens, select Add new > Browse.
    6. Find and select your target schema file, and then select Add.If your target schema doesn’t appear in the Open window, from the file type list, change XSD File (*.xsd) to All Files (*.*).The map surface now shows data types from the target schema.
    Alternatively, you can also add your source and target schema files locally to your logic app project in the Artifacts/Schemas folder, so that they appear in Visual Studio Code. In this case, you can specify your source and target schema in the Data Mapper tool on the Configure pane by selecting Select existing, rather than Add new.When you’re done, your map looks similar to the following example:Screenshot showing the Data Mapper open and data map with sample source and target schemas.

The following table describes the possible data types that might appear in a schema:Expand table

SymbolTypeMore info
Icon representing an Array data type.ArrayContains items or repeating item nodes
Icon representing a Binary data type.Binary
Icon representing a Bool data type.BoolTrue or false only
Icon representing a Complex data type.ComplexAn XML object with children properties, similar to the Object JSON type
Icon representing a DateTime data type.DateTime
Icon representing a Decimal data type.Decimal
Icon representing an Integer data type.IntegerWhole numbers only
Icon representing the NULL symbol.NullNot a data type, but appears when an error or an invalid type exists
Icon representing a Number data type.NumberA JSON integer or decimal
Icon representing an Object data type.ObjectA JSON object with children properties, similar to the Complex XML type
Icon representing a String data type.String

Create a direct mapping between elements

For a straightforward transformation between elements with the same type in the source and target schemas, follow these steps:

  1. To review what happens in code while you create the mapping, in the map’s upper right corner, select Show code.
  2. If you haven’t already, on the map, select the target elements and then the source elements that you want to map.
  3. Move your pointer over the source element so that both a circle and a plus sign (+) appear.Screenshot showing the data map and starting a mapping between EmployeeID and ID in the source and target schema, respectively.
  4. Drag a line to the target element so that the line connects to the circle that appears.Screenshot showing the data map and ending a mapping between EmployeeID and ID in the source and target schema, respectively.You’ve now created a direct mapping between both elements.Screenshot showing the data map and a finished mapping between EmployeeID and ID in the source and target schema, respectively.The code view window reflects the mapping relationship that you created:Screenshot showing code view with direct mapping between EmployeeID and ID in the source and target schema, respectively.

 Note: If you create a mapping between elements where their data types don’t match, a warning appears on the target element, for example:

Screenshot showing direct mapping between mismatching data types.

Advantages of Using Data Mapper in VS Code

The integration of the Data Mapper in VS Code offers several benefits:

  • Unified Experience: The Data Mapper provides a cohesive environment for both mapping and transformation tasks, reducing the need for manual coding.
  • Visual Aid: The tool’s visualization capabilities make understanding and editing data maps more intuitive.
  • Developer Productivity: Live code changes and breadcrumb navigation enhance developer efficiency, allowing for a focus on specific sections of the map.
  • Testing Capabilities: The ability to test maps with sample messages and view outputs streamlines the validation process.

Limitations and Known Issues

While the Data Mapper is a powerful tool, it’s important to note its current limitations:

  • It only operates within VS Code running on Windows operating systems.
  • The Code view pane of the Data Mapper is read-only, and the layout is automatic and non-editable.

Conclusion

The Logic App Data Mapper in Visual Studio Code is a transformative tool that simplifies the process of data transformation within Azure Logic Apps workflows. By following the steps outlined above and taking advantage of the tool’s features, developers can enhance their productivity and ensure seamless data integration across various platforms.

For those seeking to delve deeper into the capabilities of the Logic App Data Mapper, numerous resources and tutorials are available online, including comprehensive guides on Microsoft’s official documentation and instructional videos that provide step-by-step walkthroughs.

Embrace the power of the Logic App Data Mapper in Visual Studio Code and elevate your data transformation processes to new heights of efficiency and clarity.

References

Spread the love

Sagar Sharma