Wednesday 2 January 2019

Liquid Transformation As a Azure Function using DotLiquid

In this article, I would brief about achieving Liquid Template Transformation using DotLiquid in a Azure Function.

Using Azure SDK, I have create a simple HTTP Trigger function. This has two projects, LiquidTransformationApp(LiquidTransformation) and AzureFunctions.Helper.

In LiquidTransformation, we extract the request body, map name and map type from the query string and invoke utility helper for the transformation, as shown

Here is utility helper class with does the Parse and Render of the Liquid Template. I have embedded the liquid templates as as resource files and based on the MapName and MapType, we would dynamically execute the transformation and render the transformed result as HTTP Response to client. 

Here, we receive JSON request and JSON request would contain nested JObject/Array, thus to parse the JSON request as Dictionary Object, we use ParseJSONHelper and GenericInterface<T> and Generic<T> are used in Parse and Render stages of Liquid Templates to achieve support for dynamic objects.

Here are the Json To Json and Json To XML Transformation liquid templates.
Lets run and verify the Liquid Template Transformation

No comments:

Post a Comment

Note: only a member of this blog may post a comment.