question

averroes avatar image
0 Votes"
averroes asked PramodValavala-MSFT answered

Is there a way to import an Azure Function into API Management via REST service?

Is there a way to import an Azure Function into API Management via REST service? Are there other programmatic ways if not?

azure-functionsazure-api-management
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

learn2skills avatar image
0 Votes"
learn2skills answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PramodValavala-MSFT avatar image
0 Votes"
PramodValavala-MSFT answered

@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

  1. Get HTTP Trigger Functions defined using the List Functions API and filter for ones that have the href property

  2. Create an API using the APIs - Create or Update API

  3. 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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.