|
1 | 1 | ---
|
2 | 2 | title: Import an Azure Function App as an API in API Management
|
3 | 3 | titleSuffix: Azure API Management
|
4 |
| -description: This article shows you how to import an Azure Function App into Azure API Management as an API. |
| 4 | +description: Learn how to import an Azure function app into Azure API Management as an API. |
5 | 5 | services: api-management
|
6 | 6 | author: dlepow
|
7 | 7 | ms.service: azure-api-management
|
8 | 8 | ms.topic: how-to
|
9 |
| -ms.date: 04/16/2021 |
| 9 | +ms.date: 03/28/2025 |
10 | 10 | ms.author: danlep
|
| 11 | + |
| 12 | +#customer intent: As an API developer, I want to import an Azure function app as an API in API Management. |
11 | 13 | ---
|
12 | 14 |
|
13 |
| -# Import an Azure Function App as an API in Azure API Management |
| 15 | +# Import an Azure function app as an API in Azure API Management |
14 | 16 |
|
15 | 17 | [!INCLUDE [api-management-availability-all-tiers](../../includes/api-management-availability-all-tiers.md)]
|
16 | 18 |
|
17 |
| -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. |
| 19 | +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 API Management. |
18 | 20 |
|
19 | 21 | [!INCLUDE [api-management-workspace-availability](../../includes/api-management-workspace-availability.md)]
|
20 | 22 |
|
21 |
| -This article walks through importing and testing an Azure Function App as an API in Azure API Management. |
| 23 | +This article describes how to import an Azure function app as an API to Azure API Management and test the API. |
22 | 24 |
|
23 |
| -You will learn how to: |
| 25 | +You'll learn how to: |
24 | 26 |
|
25 | 27 | > [!div class="checklist"]
|
26 |
| -> * Import an Azure Function App as an API |
27 |
| -> * Append an Azure Function App to an API |
28 |
| -> * View the new Azure Function App host key and Azure API Management named value |
| 28 | +> * Import an Azure function app as an API |
| 29 | +> * Append an Azure function app to an API |
| 30 | +> * View the new function app host key and API Management named value |
29 | 31 | > * Test the API in the Azure portal
|
30 | 32 |
|
31 | 33 | ## Prerequisites
|
32 | 34 |
|
33 | 35 | * Complete the [Create an Azure API Management instance](get-started-create-service-instance.md) quickstart.
|
34 |
| -* Make sure you have an Azure Functions app in your subscription. For more information, see [Create an Azure Function App](../azure-functions/functions-get-started.md). Functions must have HTTP trigger and authorization level set to *Anonymous* or *Function*. |
| 36 | +* Make sure you have an Azure function app in your subscription. For more information, see [Getting started with Azure Functions](../azure-functions/functions-get-started.md). The function must have an HTTP trigger. The authorization level must be set to *Anonymous* or *Function*. |
35 | 37 |
|
36 | 38 | > [!NOTE]
|
37 |
| -> You can use the API Management Extension for Visual Studio Code to import and manage your APIs. Follow the [API Management Extension tutorial](visual-studio-code-tutorial.md) to install and get started. |
38 |
| -
|
39 |
| -[!INCLUDE [api-management-navigate-to-instance.md](../../includes/api-management-navigate-to-instance.md)] |
| 39 | +> You can also use the API Management Extension for Visual Studio Code to import and manage your APIs. Complete the [API Management Extension tutorial](visual-studio-code-tutorial.md) to get started. |
40 | 40 |
|
41 |
| -## <a name="add-new-api-from-azure-function-app"></a> Import an Azure Function App as a new API |
| 41 | +## Import an Azure function app as a new API |
42 | 42 |
|
43 |
| -Follow the steps below to create a new API from an Azure Function App. |
| 43 | +To create a new API from an Azure function app: |
44 | 44 |
|
45 |
| -1. Navigate to your API Management service in the Azure portal and select **APIs** from the menu. |
| 45 | +1. Navigate to your API Management service in the Azure portal. |
| 46 | +1. Select **APIs** > **APIs** in the left pane. |
46 | 47 |
|
47 |
| -2. In the **Add a new API** list, select **Function App**. |
| 48 | +1. Under **Create from Azure resource**, select **Function App**: |
48 | 49 |
|
49 |
| - :::image type="content" source="./media/import-function-app-as-api/add-01.png" alt-text="Screenshot that shows the Function App tile."::: |
| 50 | + :::image type="content" source="./media/import-function-app-as-api/add-01.png" alt-text="Screenshot that shows the Function App tile in the Azure portal."::: |
50 | 51 |
|
51 |
| -3. Click **Browse** to select Functions for import. |
| 52 | +1. Select the **Browse** button: |
52 | 53 |
|
53 |
| - :::image type="content" source="./media/import-function-app-as-api/add-02.png" alt-text="Screenshot that highlights the Browse button."::: |
| 54 | + :::image type="content" source="./media/import-function-app-as-api/add-02.png" alt-text="Screenshot that highlights the Browse button." lightbox="./media/import-function-app-as-api/add-02.png"::: |
54 | 55 |
|
55 |
| -4. Click on the **Function App** section to choose from the list of available Function Apps. |
| 56 | +1. Click the **Select** button under **Configure required settings** to choose from the list of available function apps: |
56 | 57 |
|
57 |
| - :::image type="content" source="./media/import-function-app-as-api/add-03.png" alt-text="Screenshot that highlights the Function App section."::: |
| 58 | + :::image type="content" source="./media/import-function-app-as-api/add-03.png" alt-text="Screenshot that shows the Select button." lightbox="./media/import-function-app-as-api/add-03.png"::: |
58 | 59 |
|
59 |
| -5. Find the Function App you want to import Functions from, click on it and press **Select**. |
| 60 | +1. Find the function app that you want to import functions from, select it, and then click **Select**: |
60 | 61 |
|
61 |
| - :::image type="content" source="./media/import-function-app-as-api/add-04.png" alt-text="Screenshot that highlights the Function App you want to import Functions from and the Select button."::: |
| 62 | + :::image type="content" source="./media/import-function-app-as-api/add-04.png" alt-text="Screenshot that shows a function app and the Select button." lightbox="./media/import-function-app-as-api/add-04.png"::: |
62 | 63 |
|
63 |
| -6. Select the Functions you would like to import and click **Select**. |
64 |
| - * You can only import Functions based off HTTP trigger with *Anonymous* or *Function* authorization levels. |
| 64 | +1. Select the functions that you want to import and click **Select**. You can only import functions that have an HTTP trigger and an *Anonymous* or *Function* authorization level. |
65 | 65 |
|
66 |
| - :::image type="content" source="./media/import-function-app-as-api/add-05.png" alt-text="Screenshot that highlights the Functions to import and the Select button."::: |
| 66 | + :::image type="content" source="./media/import-function-app-as-api/add-05.png" alt-text="Screenshot that shows a function and the Select button." lightbox="./media/import-function-app-as-api/add-05.png"::: |
67 | 67 |
|
68 |
| -7. Switch to the **Full** view and assign **Product** to your new API. |
69 |
| -8. If needed, specify other fields during creation or configure them later via the **Settings** tab. |
70 |
| - * The settings are explained in the [Import and publish your first API](import-and-publish.md#import-and-publish-a-backend-api) tutorial. |
| 68 | +1. Switch to the **Full** view and assign a **Product** to your new API. |
71 | 69 |
|
72 |
| - >[!NOTE] |
73 |
| - > Products are associations of one or more APIs offered to developers through the developer portal. First, developers must subscribe to a product to get access to the API. Once subscribed, they get a subscription key for any API in that product. As creator of the API Management instance, you are an administrator and are subscribed to every product by default. |
| 70 | + >[!NOTE] |
| 71 | + > *Products* are associations of one or more APIs that are offered to developers via the developer portal. First, developers must subscribe to a product to get access to the API. When they subscribe, they get a subscription key for any API in the product. If you created the API Management instance, you're an administrator and are subscribed to every product by default. |
74 | 72 | >
|
75 |
| - > Each API Management instance comes with two default sample products: |
| 73 | + > In some pricing tiers, API Management instances come with two default sample products: |
76 | 74 | > - **Starter**
|
77 | 75 | > - **Unlimited**
|
78 | 76 |
|
79 |
| -9. Click **Create**. |
| 77 | +1. As needed, specify other settings. You can also specify settings later via the **Settings** tab. These settings are explained in the [Import and publish your first API](import-and-publish.md#import-and-publish-a-backend-api) tutorial. |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | +1. Select **Create**. |
80 | 82 |
|
81 |
| -## <a name="append-azure-function-app-to-api"></a> Append Azure Function App to an existing API |
| 83 | +## Append a function app to an existing API |
82 | 84 |
|
83 |
| -Follow the steps below to append Azure Function App to an existing API. |
| 85 | +To append a function app to an existing API: |
84 | 86 |
|
85 |
| -1. In your **Azure API Management** service instance, select **APIs** from the menu on the left. |
| 87 | +1. In your **Azure API Management** service instance, select **APIs** > **APIs** in the left pane. |
86 | 88 |
|
87 |
| -2. Choose an API you want to import an Azure Function App to. Click **...** and select **Import** from the context menu. |
| 89 | +1. Choose an API that you want to import a function app to. Select the ellipsis (**...**) next to the API, and then select **Import**: |
88 | 90 |
|
89 |
| - :::image type="content" source="./media/import-function-app-as-api/append-function-api-1.png" alt-text="Screenshot that highlights the Import menu option."::: |
| 91 | + :::image type="content" source="./media/import-function-app-as-api/append-function-api-1.png" alt-text="Screenshot that shows the Import menu option." lightbox="./media/import-function-app-as-api/append-function-api-1.png"::: |
90 | 92 |
|
91 |
| -3. Click on the **Function App** tile. |
| 93 | +1. Select the **Function App** tile: |
92 | 94 |
|
93 |
| - :::image type="content" source="./media/import-function-app-as-api/append-function-api-2.png" alt-text="Screenshot that highlights the Function App tile."::: |
| 95 | + :::image type="content" source="./media/import-function-app-as-api/append-function-api-2.png" alt-text="Screenshot that shows the Function App tile." lightbox="./media/import-function-app-as-api/append-function-api-2.png"::: |
94 | 96 |
|
95 |
| -4. In the pop-up window, click **Browse**. |
| 97 | +1. In the **Import from Function App window**, select **Browse**: |
96 | 98 |
|
97 |
| - :::image type="content" source="./media/import-function-app-as-api/append-function-api-3.png" alt-text="Screenshot that shows the Browse button."::: |
| 99 | + :::image type="content" source="./media/import-function-app-as-api/append-function-api-3.png" alt-text="Screenshot that shows the Browse button." lightbox="./media/import-function-app-as-api/append-function-api-3.png"::: |
98 | 100 |
|
99 |
| -5. Click on the **Function App** section to choose from the list of available Function Apps. |
| 101 | +1. Click the **Select** button under **Configure required settings** to choose from the list of available function apps: |
100 | 102 |
|
101 |
| - :::image type="content" source="./media/import-function-app-as-api/add-03.png" alt-text="Screenshot that highlights the list of Function Apps."::: |
| 103 | + :::image type="content" source="./media/import-function-app-as-api/add-03.png" alt-text="Screenshot that shows the Function App section." lightbox="./media/import-function-app-as-api/add-03.png"::: |
102 | 104 |
|
103 |
| -6. Find the Function App you want to import Functions from, click on it and press **Select**. |
| 105 | +1. Find the function app you want to import functions from, select it, and then click **Select**: |
104 | 106 |
|
105 |
| - :::image type="content" source="./media/import-function-app-as-api/add-04.png" alt-text="Screenshot that highlights the Function App you want to import functions from."::: |
| 107 | + :::image type="content" source="./media/import-function-app-as-api/add-04.png" alt-text="Screenshot that shows the function app and the Select button." lightbox="./media/import-function-app-as-api/add-04.png"::: |
106 | 108 |
|
107 |
| -7. Select the Functions you would like to import and click **Select**. |
| 109 | +1. Select the functions that you want to import, and then click **Select**: |
108 | 110 |
|
109 |
| - :::image type="content" source="./media/import-function-app-as-api/add-05.png" alt-text="Screenshot that highlights the functions you'd like to import."::: |
| 111 | + :::image type="content" source="./media/import-function-app-as-api/add-05.png" alt-text="Screenshot that shows the list of functions." lightbox="./media/import-function-app-as-api/add-05.png"::: |
110 | 112 |
|
111 |
| -8. Click **Import**. |
| 113 | +1. Select **Import**: |
112 | 114 |
|
113 |
| - :::image type="content" source="./media/import-function-app-as-api/append-function-api-4.png" alt-text="Append from Function App"::: |
| 115 | + :::image type="content" source="./media/import-function-app-as-api/append-function-api-4.png" alt-text="Screenshot that shows the Import button." lightbox="./media/import-function-app-as-api/append-function-api-4.png"::: |
114 | 116 |
|
115 |
| -## <a name="authorization"></a> Authorization |
| 117 | +## Authorization |
116 | 118 |
|
117 |
| -Import of an Azure Function App automatically generates: |
| 119 | +When you import an Azure function app, these items are automatically generated: |
118 | 120 |
|
119 |
| -* Host key inside the Function App with the name apim-{*your Azure API Management service instance name*}, |
120 |
| -* Named value inside the Azure API Management instance with the name {*your Azure Function App instance name*}-key, which contains the created host key. |
| 121 | +* A host key in the function app. The key is named `apim-<your API Management service instance name>`. |
| 122 | +* A named value in the API Management instance that has the name `<your Azure function app instance name>-key`. This value contains the host key. |
121 | 123 |
|
122 |
| -For APIs created after April 4th 2019, the host key is passed in HTTP requests from API Management to the Function App in a header. Older APIs pass the host key as [a query parameter](../azure-functions/functions-bindings-http-webhook-trigger.md#api-key-authorization). You can change this behavior through the `PATCH Backend` [REST API call](/rest/api/apimanagement/current-ga/backend/update#backendcredentialscontract) on the *Backend* entity associated with the Function App. |
| 124 | +For APIs created after April 4, 2019, the host key is passed in HTTP requests from API Management to the function app in a header. Older APIs pass the host key as [a query parameter](../azure-functions/functions-bindings-http-webhook-trigger.md#api-key-authorization). You can change this behavior by using the `PATCH Backend` [REST API call](/rest/api/apimanagement/current-ga/backend/update#backendcredentialscontract) on the `Backend` entity that's associated with the function app. |
123 | 125 |
|
124 | 126 | > [!WARNING]
|
125 |
| -> Removing or changing either the Azure Function App host key value or the Azure API Management named value will break the communication between the services. The values do not sync automatically. |
| 127 | +> Removing or changing either the Azure function app host key value or the API Management named value will disable communication between the services. The values don't automatically sync. |
126 | 128 | >
|
127 |
| -> If you need to rotate the host key, make sure the named value in Azure API Management is also modified. |
| 129 | +> If you need to rotate the host key, be sure to also change the named value in API Management. |
128 | 130 |
|
129 |
| -### Access Azure Function App host key |
| 131 | +### Access a function app host key |
130 | 132 |
|
131 |
| -1. Navigate to your Azure Function App instance. |
| 133 | +1. Navigate to your Azure function app instance: |
132 | 134 |
|
133 |
| - :::image type="content" source="./media/import-function-app-as-api/keys-01.png" alt-text="Screenshot that highlights selecting your Function app instance."::: |
| 135 | + :::image type="content" source="./media/import-function-app-as-api/keys-01.png" alt-text="Screenshot that shows a list of function app instances." lightbox="./media/import-function-app-as-api/keys-01.png"::: |
134 | 136 |
|
135 |
| -2. In the **Functions** section of the side navigation menu, select **App keys**. |
| 137 | +1. In the **Functions** section of the left pane, select **App keys**: |
136 | 138 |
|
137 |
| - :::image type="content" source="./media/import-function-app-as-api/keys-02b.png" alt-text="Screenshot that highlights the Function Apps settings option."::: |
| 139 | + :::image type="content" source="./media/import-function-app-as-api/keys-02b.png" alt-text="Screenshot that shows App keys in the menu." lightbox="./media/import-function-app-as-api/keys-02b.png"::: |
138 | 140 |
|
139 |
| -3. Find the keys under the **Host keys** section. |
| 141 | +1. Find the keys in the **Host keys** section: |
140 | 142 |
|
141 |
| - :::image type="content" source="./media/import-function-app-as-api/keys-03.png" alt-text="Screenshot that highlights the Host Keys section."::: |
| 143 | + :::image type="content" source="./media/import-function-app-as-api/keys-03.png" alt-text="Screenshot that shows the host keys." lightbox="./media/import-function-app-as-api/keys-03.png"::: |
142 | 144 |
|
143 |
| -### Access the named value in Azure API Management |
| 145 | +### Access the named value in API Management |
144 | 146 |
|
145 |
| -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. |
| 147 | +Navigate to your API Management instance and select **APIs** > **Named values** in the left pane. The Azure function app key is stored there. |
146 | 148 |
|
147 |
| -:::image type="content" source="./media/import-function-app-as-api/api-named-value.png" alt-text="Add from Function App"::: |
| 149 | +:::image type="content" source="./media/import-function-app-as-api/api-named-value.png" alt-text="Screenshot that shows the location of the function app key." lightbox="./media/import-function-app-as-api/api-named-value.png"::: |
148 | 150 |
|
149 |
| -## <a name="test-in-azure-portal"></a> Test the new API in the Azure portal |
| 151 | +## Test the new API in the Azure portal |
150 | 152 |
|
151 | 153 | 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.
|
152 | 154 |
|
153 |
| -:::image type="content" source="./media/import-function-app-as-api/test-api.png" alt-text="Screenshot that highlights the test procedure."::: |
| 155 | +:::image type="content" source="./media/import-function-app-as-api/test-api.png" alt-text="Screenshot that shows the steps for testing an API." lightbox="./media/import-function-app-as-api/test-api.png"::: |
154 | 156 |
|
155 | 157 | 1. Select the API that you created in the preceding section.
|
156 | 158 |
|
157 |
| -2. Select the **Test** tab. |
| 159 | +1. Select the **Test** tab. |
158 | 160 |
|
159 |
| -3. Select the operation you want to test. |
| 161 | +1. Select the operation that you want to test. |
160 | 162 |
|
161 | 163 | * The page displays fields for query parameters and headers.
|
162 |
| - * One of the headers is "Ocp-Apim-Subscription-Key", for the product subscription key associated with this API. |
163 |
| - * As creator of the API Management instance, you are an administrator already, so the key is filled in automatically. |
| 164 | + * One of the headers is `Ocp-Apim-Subscription-Key`. This header is for the product subscription key that's associated with the API. |
| 165 | + * If you created the API Management instance, you're an administrator, so the key is filled in automatically. |
164 | 166 |
|
165 |
| -4. Select **Send**. |
| 167 | +1. Select **Send**. |
166 | 168 |
|
167 |
| - * When the test succeeds, the back end responds with **200 OK** and some data. |
| 169 | + When the test succeeds, the backend responds with **200 OK** and some data. |
168 | 170 |
|
169 | 171 | [!INCLUDE [api-management-define-api-topics.md](../../includes/api-management-define-api-topics.md)]
|
0 commit comments