Примечание
Для доступа к этой странице требуется авторизация. Вы можете попробовать войти или изменить каталоги.
Для доступа к этой странице требуется авторизация. Вы можете попробовать изменить каталоги.
ОБЛАСТЬ ПРИМЕНЕНИЯ: все уровни Управления API
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.
Примечание.
В настоящее время эта функция недоступна в рабочих областях.
This article describes how to import an Azure function app as an API to Azure API Management and test the API.
Вы узнаете, как:
- Import an Azure function app as an API
- Append an Azure function app to an API
- View the new function app host key and API Management named value
- проверка API на портале Azure;
Предварительные условия
- Complete the Create an Azure API Management instance quickstart.
- Make sure you have an Azure function app in your subscription. For more information, see Getting started with Azure Functions. The function must have an HTTP trigger. The authorization level must be set to Anonymous or Function.
Примечание.
You can also use the API Management Extension for Visual Studio Code to import and manage your APIs. Complete the API Management Extension tutorial to get started.
Import an Azure function app as a new API
To create a new API from an Azure function app:
Перейдите к службе управления API на портале Azure.
Select APIs>APIs in the left pane.
Under Create from Azure resource, select Function App:
Select the Browse button:
Click the Select button under Configure required settings to choose from the list of available function apps:
Find the function app that you want to import functions from, select it, and then click Select:
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.
Switch to the Full view and assign a Product to your new API.
Примечание.
Products are associations of one or more APIs that are offered to developers via the developer portal. Чтобы получить доступ к 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.
In some pricing tiers, API Management instances come with two default sample products:
- Starter
- Unlimited
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 tutorial.
Выберите Создать.
Append a function app to an existing API
To append a function app to an existing API:
In your Azure API Management service instance, select APIs>APIs in the left pane.
Choose an API that you want to import a function app to. Select the ellipsis (...) next to the API, and then select Import:
Select the Function App tile:
In the Import from Function App window, select Browse:
Click the Select button under Configure required settings to choose from the list of available function apps:
Find the function app you want to import functions from, select it, and then click Select:
Select the functions that you want to import, and then click Select:
Select Import:
Авторизация
When you import an Azure function app, these items are automatically generated:
- A host key in the function app. The key is named
apim-<your API Management service instance name>
. - 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.
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. Более старые API передают ключ узла в виде параметра запроса. You can change this behavior by using the PATCH Backend
REST API call on the Backend
entity that's associated with the function app.
Предупреждение
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.
If you need to rotate the host key, be sure to also change the named value in API Management.
Access a function app host key
Navigate to your Azure function app instance:
In the Functions section of the left pane, select App keys:
Find the keys in the Host keys section:
Access the named value in API Management
Navigate to your API Management instance and select APIs>Named values in the left pane. The Azure function app key is stored there.
Проверка нового API на портале Azure
Операции можно вызывать непосредственно на портале Azure. Использование портала Azure — удобный способ просмотра и тестирования операций с API.
Выберите API, созданный на предыдущем шаге.
Откройте вкладку Тест.
Select the operation that you want to test.
- На странице отображаются поля для параметров запроса и заголовков.
- Одним из заголовков является
Ocp-Apim-Subscription-Key
. Этот заголовок предназначен для ключа подписки продукта, связанного с API. - Если вы создали экземпляр службы управления API, вы являетесь администратором, поэтому ключ заполняется автоматически.
Выберите Отправить.
When the test succeeds, the backend responds with 200 OK and some data.
Связанный контент
- Ограничения импорта API
- Импорт спецификации OpenAPI
- Import a SOAP API
- импортируйте API SOAP и преобразуйте его в REST
- Импорт API Службы приложений
- Импорт API контейнерного приложения
- Import a WebSocket API
- Импортировать API GraphQL
- Импорт схемы GraphQL и настройка сопоставителей полей
- Импортировать API приложения Azure Function
- Импорт API логического приложения Azure
- Import a Service Fabric service
- Импортировать API Azure OpenAI
- Import an OData API
- Импорт метаданных SAP OData
- Import a gRPC API
- Изменение API