Create swagger api endpoint for Azure functions

In my previous article, we saw detailed step on how to create a server-less function using Azure Function. If you are not familiar with Azure Function topic I highly recommend you to have a look before we proceed here.

Alright, In this article will see how to create/configure OpenApi for our Crypto Function and to be able to use in other applications. Before proceeding there let us understand OpenApi protocol.

What is OpenApi?

An open API (often referred to as a public API) is a publicly available application programming interface that provides developers with programmatic access to a proprietary software application or web service. APIs are sets of requirements that govern how one application can communicate and interact with another. - Wikipedia
Basically, OpenApi provides its consumers a rich set of functionalities in a single EndPoint and to be able to access from any ecosystem.These Api are public or private based on the use-case.

Like I mentioned already Crypto Azure Function it offers server-less function as a WebApi EndPoint and off-course it is secured based on the secret code key(It can also be configurable for Anonymous access).

Create Swagger/OpenApi for Azure functions

Go to https://portal.azure.com/  and select Azure functions, Click Crypto Function to note down the function secret code for later use

Select Api definition
Click "Generate Api definition template" Azure would automatically scan your function code and give us matching empty YAML template.(you can omit the below error in your application initially because that what we are going to fix).


Default YAML template looks like below

I have modified YAML code based on my use-case like below

Note: Highly recommend you to go through OpenApi(Swagger) documentation and consider above yaml just for reference to my azure function implementation. Once yaml is configured properly we can test it in the right pane
First, provide function authenticate secret code (which I copied earlier)

Click on 'try this operation'

fill parameters values

click "Send Request" for testing 



-Ratsub

Related Article:
Configure Custom connectors to PowerApps & MSFlow
Create serverless Azure Functions
Create People Picker control in PowerApps
Create Multilingual app using PowerApps

Comments

Popular posts from this blog

Secure When a HTTP request is received Power Automate a.k.a MS Flow

People picker Control in PowerApps

Upload attachment to SharePoint list item using Microsoft Flow

Approval and auto escalation with time out in Microsoft Flow

Modern page provisioning using page template

Headless-Daemon calling AAD secured API

Developing custom reusable components in PowerApps

Step-By-Step Azure AD App Registration

HTML field & Date Time formatting in powerapps

Create and configure custom connectors for PowerApps and MSFlow from AzureFunctions