Open API Specification in Azure Functions

Posted: June 14, 2021  |  Categories: Azure Function Logic Apps Open API
Tags:

After a very long “winter” I’m back. ๐Ÿ™‚

To start with I’ll be sharing in this post how I did an Azure Function implementation with custom routes to show in Logic Apps.

So, the client that I’m working for requested to me to create an alternative to executing Liquid maps in Azure Functions instead of the Integration Account. As I knew there are solutions out there that people already made I went to search for it and I found this: https://github.com/olafloogman/functions-dotnet-liquidtransform.

It’s a pretty complete example of how to execute Liquid maps in an Azure Function, so I used this as a reference to build my own version, and in case you want to see more in detail, just follow the link.

The signature of this function is as this:

You can see that the Route setting for the was specified for the HttpRequestMessage parameter attribute.

The thing is that Logic Apps does not support custom routes in Azure Functions as stated by Jeff Hollan here https://github.com/Azure/Azure-Functions/issues/621, and you can see in the picture below, when I tried to add it in Logic Apps, nothing was being shown in the Actions:

As indicated in the response he gave I could go around this issue by creating an Open API specification. That was really great as I could still keep my function as I wanted.

After some research I found an article that was written by Justin Yoo, talking about a package he did but since I wanted to use something more official I kekp looking and I found this other article and nuget package that I believe was based on the work he did previously:

Basically I needed to import this package in my solution and add a few attributes to my function as below:

These attribute will be used to generate the Open API specification as you can see in the image below:

Open API Specification

So, once I had the function deployed, I could make changes in the API definition settings to specify the location of the Open API specification.

Another thing I had to do was to configure CORS to accept “*” as Allowed Origins.

With all of that done, I can now go back to my Logic Apps and try again to look up for the actions, and on the Swagger actions tab I can see it.

Summary

So, with a few more work on your Azure Functions that have custom routes you can enable them to also been seeing by Logic Apps.

Hope you enjoyed the reading and I’ll try to start posting more from now on.

Cheers!!!

Author: Alessandro Moura

Certified BizTalk, Mulesoft, TOGAF and Azure. Integration Specialist. Solutions Architect.

Leave a Reply

turbo360

Back to Top