Azure API Management provides HTTP API consumers with a consistent way of using API gateway features for back-end API services. You can integrate your Azure Function app with Azure API Management by directly importing the Function app. But you can also make use of this OpenAPI extension so that everything will be set up at one go.
To get yourself started, you need to have the followings installed on your local machine.
There are several ways to create an Azure API Management instance. But Azure CLI will be used here. Run the following command in your shell:
az apim create \
-g [RESOURCE_GROUP_NAME] \
-n [API_MANAGEMENT_INSTANCE_NAME] \
-l [LOCATION] \
--sku-name Consumption \
--publisher-name contoso.com \
--publisher-email [email protected]
--no-wait
Make sure that, as creating an Azure API Management instance takes about 30-40 minutes, adding the
--no-wait
parameter would be nice. Also use the SKU ofConsumption
instead of the default SKU (Developer
) to reduce the instance generation time for this practice. TheConsumption
tier takes up to two minutes for instance creation.
Please refer to the Azure Function app with the OpenAPI extension enabled. Once the Function app is deployed to Azure, make sure you can generate swagger.json
document on-the-fly.
Copy the URL of the swagger.json
for later use.
The sample Function app code can be found at this GitHub repository.
On you Azure API Management instance, select APIs
blade, select + Add API
tab and click the OpenAPI
panel.
Paste the URL copied from the previous step into the OpenAPI specification
field and enter contoso
into the API URL suffix
field. All the rest are automatically filled in.
Azure Functions API is now successfully imported.
To test the imported API endpoint, go to the newly imported API by clicking the APIs
blade, clicking the OpenAPI Sample on Azure...
tab and choosing one of API endpoints, and selecting the Test
tab.
Enter relevant information to the given fields anc click the Send
button
Confirm the test has been successfully performed.
When you continue to the another step, [Support Azure Functions v1 with OpenAPI Extension][docs v1 suppport], you'll need to keep all your resources in place to build on what you've already done.
Otherwise, you can use the following steps to delete the function app and its related resources to avoid incurring any further costs.
-
In Visual Studio Code, press F1 to open the command palette. In the command palette, search for and select
Azure Functions: Open in portal
. -
Choose your function app, and press Enter. The function app page opens in the Azure portal.
-
In the Overview tab, select the named link next to Resource group.
-
In the Resource group page, review the list of included resources, and verify that they are the ones you want to delete.
-
Select Delete resource group, and follow the instructions.
Deletion may take a couple of minutes. When it's done, a notification appears for a few seconds. You can also select the bell icon at the top of the page to view the notification.
To learn more about Functions costs, see Estimating Consumption plan costs. To learn more about API Management costs, see Feature-based comparison of the Azure API Management tiers.
You have got an Azure API Management integrated with Azure Functions that implements the OpenAPI extension. In the next articles, you will be able to support Azure Functions v1 runtime or integrate this OpenAPI-enabled Azure Functions app with either Azure Logic Apps or Power Platform.