Import an Azure Function App as an API in Azure API Management
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.
This article walks through importing an Azure Function App as an API in Azure API Management. It also describes the testing process.
You will learn how to:
- Import an Azure Function App as an API
- Append an Azure Function App to an API
- View the new Azure Function App host key and Azure API Management named value
- Test the API in the Azure portal
- Test the API in the developer portal
Prerequisites
- Complete the quickstart Create an Azure API Management instance.
- Make sure you have an Azure Functions app in your subscription. For more information, see Create an Azure Function App. It has to contain Functions with HTTP trigger and authorization level setting set to Anonymous or Function.
Go to your API Management instance
Sign in to the Azure portal.
Select All services.
In the search box, enter
api management
.In the search results, select API Management services.
Select your API Management service instance.
Tip
To add API Management to your favorites in the Azure portal, select the star.
The API Management icon () now appears in the left menu in the portal.
Import an Azure Function App as a new API
Follow the steps below to create a new API from an Azure Function App.
In your Azure API Management service instance, select APIs from the menu on the left.
In the Add a new API list, select Function App.
Click Browse to select Functions for import.
Click on the Function App section to choose from the list of available Function Apps.
Find the Function App you want to import Functions from, click on it and press Select.
Select the Functions you would like to import and click Select.
Note
You can import only Functions that are based off HTTP trigger and have the authorization level setting set to Anonymous or Function.
Switch to the Full view and assign Product to your new API. If needed, edit other pre-populated fields.
Click Create.
Append Azure Function App to an existing API
Follow the steps below to append Azure Function App to an existing API.
In your Azure API Management service instance, select APIs from the menu on the left.
Choose an API you want to import an Azure Function App to. Click ... and select Import from the context menu.
Click on the Function App tile.
In the pop-up window, click Browse.
Click on the Function App section to choose from the list of available Function Apps.
Find the Function App you want to import Functions from, click on it and press Select.
Select the Functions you would like to import and click Select.
Click Import.
Generated Azure Function App host key
Import of an Azure Function App automatically generates:
- host key inside the Function App with the name apim-{your Azure API Management service instance name},
- named value inside the Azure API Management instance with the name {your Azure Function App instance name}-key, which contains the created host key.
Warning
Removing or changing value of either the Azure Function App host key or Azure API Management named value will break the communication between the services. The values do not sync automatically.
If you need to rotate the host key, make sure the named value in Azure API Management is also modified.
Access Azure Function App host key
Navigate to your Azure Function App instance.
Select Function App settings from the overview.
The key is located in the Host Keys section.
Access the named value in Azure API Management
Navigate to your Azure API Management instance and select Named values from the menu on the left. The Azure Function App key is stored there.
Test the new API Management API in the Azure portal
You can call operations directly from the Azure portal. Using the Azure portal is a convenient way to view and test the operations of an API.
Select the API that you created in the preceding section.
Select the Test tab.
Select an operation.
The page displays fields for query parameters and fields for the headers. One of the headers is Ocp-Apim-Subscription-Key, for the subscription key of the product that is associated with this API. If you created the API Management instance, you are an administrator already, so the key is filled in automatically.
Select Send.
The back end responds with 200 OK and some data.
Call an operation from the developer portal
You can also call operations from the developer portal to test APIs.
Select the API that you created in Import and publish a back-end API.
Select Developer portal.
The developer portal site opens.
Select the API that you created.
Select the operation you want to test.
Select Try it.
Select Send.
After an operation is invoked, the developer portal displays the Response status, the Response headers, and any Response content.
Related topics
- Import an OpenAPI Specification
- Import a SOAP API
- Import a SOAP API and convert to REST
- Import an Azure API app
- Import an Azure Function App
- Import an Azure Logic App
- Import a Service Fabric service
- Edit an API
Next steps
Feedback
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.
Loading feedback...