Extending Flow with Functions - Part 2
Very often there are packages out there, that we could use to extend our flow with more functionality.
In this article I will show you how to extend flow, using Azure Functions. The technique I'm going to use is:
- Create an Azure Function that take some input, does some processing, and returns a result;
- Test the function to show how it works as an API;
- Write a custom connector, so we can integrate with Flow (and PowerApps);
- Use it in Flow
In the first Part of this series, we created the Azure Function, and now in the second part, we will write the custom connector and use it in Flow.
Custom Connector- here we go
A Custom Connector is way for us to define an interface for Power Platform to communicate with our API - which in this case is the Function App we just created. We define this using OpenAPI 2.0 (formally swagger). There are a lot of tools out there to help you create your OpenApi(such as OpenApiGen), but for this we just going to create it using the swagger editor to create it.
Change the following parts of the OpenApi:
- host - set the host to the url of your azure function app
host: "liquid-flow.azurewebsites.net"
- basepath - set this to the base of the function app, by default will be /
basePath: "/"
- schemes - function apps only use https
schemes: - "https"
- Add the function, so path is /api/Liquid
/api/Liquid:
- Parameters have a body
parameters: - in: "body" name: "liquidbody" description: "Liquid Transformation" schema: $ref: "#/definitions/LiquidBodySchema"
- Response will have return an object
responses: 200: description: "OK" schema: $ref: "#/definitions/LiquidResponseSchema"
- Add the request schema
definitions: LiquidBodySchema: type: "object" properties: liquidtemplate: type: "string" description: "The Liquid Template to transform" x-ms-summary: "Liquid Template" data: type: "object" description: "Data to transform" x-ms-summary: "Data"
- Add the response schema
LiquidResponseSchema: type: "object"
By returning just an object, anything can be returned in the response
Get the JSON version, by choosing "Convert and save as JSON" from the File menu
Here are the completed files:
Add the custom connector
Lets upload our OpenApi file into PowerApps, so in PowerApps, select Data - Custom connectors
Click on the right hand side "Create custom connector"
Connector name is Liquid Templates, and add the OpenApi file
Click Create Connector and it will create the custom connector.
Test the connector
To test the connector, click on the Test tab
Create a New connection, and then put some test data into the two field:
Click the Test operation button, and you should get the result back.
NOTE: If have just created the connection, and you get a Operation failed (404), see response below error, it doesn't mean you have an error - it's PowerApps way of telling you its still setting everything up - go get a coffee and come back in 10 or 15 minutes time. Hopefully by then PowerApps has setup all the bits to get the custom connection done, and you'll get your 200 response with the output.
So we now have:
- Created our function app, and tested it;
- Created our custom connector, and tested it.
So lets use it in our flow.
Add it into our flow
Create a new flow, using a button
Add the new action, so under Custom in the choose action box, the Liquid Templates will appear
Choose the new Transform JSON using Liquid Templating engine
Insert the liquid template, and test data
Save the template, and then run it from the Flow mobile app, by pressing the button
Now you see the result
We have extended flow - by creating a new action in Flow - this case to transform Liquid Templates.
We did this by using an Azure Function, which used an already developed package to offer functionality in Flow.
I hope this shows you the possibilities that you can achieve by extending flow, and how to go about it.

Like
Report
*This post is locked for comments