Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Let's say we have to build an expense processing application. It takes the receipt with amount and currency information and converts it into final amount in US dollars based on the exchange rate.
We will use Logic Apps to build the solution. It takes the receipt information through a Request trigger, uses XML Transform to generate the final amount and returns the result using Response action. We don't want to hard-code the currency conversion rate in the XSLT map as they keep changing and will Azure Functions to look it up.
Let's start with the building blocks - Azure Function and XSLT map. Later we will stitch everything together in a Logic App.
We have a C# Webhook Function here which reads the currency information from request query parameters and gets the conversion rate to USD. Here we have hardcoded the mapping in the Function, but in a real world scenario it would be coming from a database or in real-time from a web service etc. Click here to download the source code.
The XSLT map takes Azure Function App URL as a parameter (line #5). There are several benefits of doing this -
To learn more about XSLT parameters support in Logic Apps you can try out Azure Logic Apps - XSLT with parameters on github.
It then creates the output XML consisting of original currency, original amount and calculated amount in USD. For the calculation it first call the Azure Function passing the currency as input parameter and then multiplies it with the original amount.
We have used inline C# scripting to call the Function App using the HTTP client. In this example, we are passing the input parameters through query parameters and making a GET request but it can be easily modified to do more complex things like making a POST request with XML payload in request body.
Click here to download the source code.
Let's start with creating an Integration Account first and uploading the XSLT map into it.
Next, create a Logic App in the same region and associate the Integration Account with it.
Its a simple Logic App containing a Request trigger, XML Transform action and a Response action.
The Request trigger exposes a REST endpoint and expects the receipt information (XML format) in the request body.
The Transform action shows 2 fields -
The designer detects that the map contains an input parameter called AzureFunctionUri and automatically adds another field in the action. Copy the Function URL from the Function blade and paste it here.
In the end, we call the Logic App from Postman passing in the receipt payload in the request body and get back the amount in USD.
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in