Is there a way to import an Azure Function into API Management via REST service? Are there other programmatic ways if not?
Is there a way to import an Azure Function into API Management via REST service? Are there other programmatic ways if not?
@averroes While the Azure Portal supports importing an Azure Function in an interactive fashion, the REST API itself doesn't support it directly. But even the portal does use the same APIM ARM REST APIs to create the APIs, Operations, etc. You can see the individual requests being made from the browser dev tools.
You can mimic the same requests that the portal makes to automate this. At a high level, these are the APIs you would have to leverage to achieve the same
Get HTTP Trigger Functions defined using the List Functions API and filter for ones that have the href property
Create an API using the APIs - Create or Update API
Create an operation for each endpoint using the API Operation - Create or Update API
That being said, it is much easier to import APIs using a Swagger Spec that can be done programmatically as well. While currently in preview, the Azure Functions OpenAPI Extension is the perfect fit to generate the spec for your functions, which can later be imported into APIM as-is using the APIs - Create or Update API.
Hi @averroes
Azure API Management supports importing Azure Function Apps as new APIs or appending them to existing APIs. The process automatically generates a host key in the Azure Function App, which is then assigned to a named value in Azure API Management.
Please refer to the below URL's it will help.
https://docs.microsoft.com/en-us/azure/api-management/import-function-app-as-api
https://techcommunity.microsoft.com/t5/azure-paas-blog/import-azure-function-app-to-azure-api-management/ba-p/2594810
https://www.drware.com/build-rest-apis-in-three-steps-with-api-management-and-azure-functions/
If the Answer is helpful, please click Accept Answer and up-vote, so that it can help others in the community looking for help on similar topics.
9 people are following this question.