Why are you not writing OpenAPI enabled Azure Functions ? It's 2021 !!

Azure functions has come a long way from its inception and offers great deal of capabilities . I was recently browsing through some cool stuff it can do and came across this feature. So lets dive into it.

What ? : So lets assume, I have written a cool Azure function that returns the name of next big altcoin that is going to replace Bitcoin and I want to share it with my close friends. Now instead of me writing a documentation for reach API endpoint of my function , I can simply enable my Azure function for OpenAPI and all of my friends can directly open swagger for my API to check its definitions and start using it.

Why ? :

Adding support for OpenAPI opens up the possibility to extend it to a lot of other services quite easily. A couple of them are listed below :

1. Create custom connector based on this Azure Function in less than 5 min.

2. Use the custom connectors in Canvas app as an extension.

3. Easily integrate your api to Azure APIM or any test suite of your choice for testing it out.

How ? :

  1. Install the latest version of Azure.WebJobs.Extensions.OpenApi nuget package.

  2. Open a new project in Visual Studio of type "Http trigger with OpenAPI"

3. Your new function app is ready and has automatically added OpenAPI declarations on top of main function.

4. Build and deploy the function app and you are good to go. Benefits : 1. This extension automatically adds a couple of other URLs like :

a> oauth2RedirectUrl : https://localhost:8080/api/swagger-ui/oauth2-redirect.html

b> Swagger UI : https://localhost:8080/api/swagger/UI

c> Swagger JSON : https://localhost:8080/api/swagger.json

d> Swagger document : https://localhost:8080/api/swagger.{extensions}

e> Open API document : https://localhost:8080/api/openapi/{version}.{extension}

2. Open API document supports for V3 and yaml extension in addition to json.

3. Easy integration with Logic apps / Powerapps and any other app that support OpenAPI.

Further resources link :


Enable OpenAPI documents to your Azure Functions HTTP Trigger

Integrating OpenAPI-enabled Azure Functions to Azure API Management

44 views0 comments

Recent Posts

See All