Skip to content

Commit bc72ccf

Browse files
author
gitName
committed
[APIM] AOAI backends updates
1 parent 648c1c0 commit bc72ccf

File tree

3 files changed

+78
-23
lines changed

3 files changed

+78
-23
lines changed

articles/api-management/api-management-authenticate-authorize-azure-openai.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Options to authenticate and authorize to Azure OpenAI APIs using Az
55
author: dlepow
66
ms.service: azure-api-management
77
ms.topic: article
8-
ms.date: 02/20/2024
8+
ms.date: 01/23/2025
99
ms.author: danlep
1010
ms.collection: ce-skilling-ai-copilot
1111
---
@@ -78,7 +78,7 @@ In this example, the named value in API Management is *openai-api-key*.
7878

7979
## Authenticate with managed identity
8080

81-
An alternative way to authenticate to an Azure OpenAI API by using a managed identity in Microsoft Entra ID. For background, see
81+
An alternative and recommended way to authenticate to an Azure OpenAI API is by using a managed identity in Microsoft Entra ID. For background, see
8282
[How to configure Azure OpenAI Service with managed identity](/azure/ai-services/openai/how-to/managed-identity).
8383

8484
Following are steps to configure your API Management instance to use a managed identity to authenticate requests to an Azure OpenAI API.
@@ -101,6 +101,9 @@ Following are steps to configure your API Management instance to use a managed i
101101
</set-header>
102102
```
103103

104+
> [!TIP]
105+
> An alternative to using the `authentication-managed-identity` and `set-header` policies shown in this example is to configure a [backend](backends.md) resource that directs API requests to the Azure OpenAI Service endpoint. In the backend configuration, enable managed identity authentication to the Azure OpenAI Service. Azure API Management automates these steps when importing an API directly from Azure OpenAI Service. For more information, see [Import API from Azure OpenAI Service](azure-openai-api-from-specification.md#option-1-import-api-from-azure-openai-service).
106+
104107
## OAuth 2.0 authorization using identity provider
105108

106109
To enable more fine-grained access to OpenAPI APIs by particular users or clients, you can preauthorize access to the Azure OpenAI API using OAuth 2.0 authorization with Microsoft Entra ID or another identity provider. For background, see [Protect an API in Azure API Management using OAuth 2.0 authorization with Microsoft Entra ID](api-management-howto-protect-backend-with-aad.md).

articles/api-management/azure-openai-api-from-specification.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.service: azure-api-management
55
author: dlepow
66
ms.author: danlep
77
ms.topic: how-to
8-
ms.date: 05/10/2024
8+
ms.date: 01/23/2025
99
ms.collection: ce-skilling-ai-copilot
1010
ms.custom: template-how-to, build-2024
1111
---
@@ -16,8 +16,8 @@ ms.custom: template-how-to, build-2024
1616

1717
This article shows two options to import an [Azure OpenAI Service](/azure/ai-services/openai/overview) API into an Azure API Management instance as a REST API:
1818

19-
- [Import an Azure OpenAI API directly from Azure OpenAI Service](#option-1-import-api-from-azure-openai-service)
20-
- [Download and add the OpenAPI specification](#option-2-add-an-openapi-specification-to-api-management) for Azure OpenAI and add it to API Management as an OpenAPI API.
19+
- [Import an Azure OpenAI API directly from Azure OpenAI Service](#option-1-import-api-from-azure-openai-service) (recommended)
20+
- [Download the OpenAPI specification](#option-2-add-an-openapi-specification-to-api-management) and add it to API Management as an OpenAPI API.
2121

2222
## Prerequisites
2323

@@ -37,9 +37,9 @@ When you import the API, API Management automatically configures:
3737

3838
* Operations for each of the Azure OpenAI [REST API endpoints](/azure/ai-services/openai/reference).
3939
* A system-assigned identity with the necessary permissions to access the Azure OpenAI resource.
40-
* A [backend](backends.md) resource and [set-backend-service](set-backend-service-policy.md) policy that direct API requests to the Azure OpenAI Service endpoint.
41-
* An [authentication-managed-identity](authentication-managed-identity-policy.md) policy that can authenticate to the Azure OpenAI resource using the instance's system-assigned identity.
42-
* (optionally) Policies to help you monitor and manage token consumption by the Azure OpenAI API.
40+
* A [backend](backends.md) resource and a [set-backend-service](set-backend-service-policy.md) policy that direct API requests to the Azure OpenAI Service endpoint.
41+
* Authentication to the Azure OpenAI backend using the instance's system-assigned managed identity.
42+
* (optionally) Policies to help you monitor and manage the Azure OpenAI API.
4343

4444
To import an Azure OpenAI API to API Management:
4545

@@ -57,8 +57,14 @@ To import an Azure OpenAI API to API Management:
5757

5858
For example, if your API Management gateway endpoint is `https://contoso.azure-api.net`, set a **Base URL** similar to `https://contoso.azure-api.net/my-openai-api/openai`.
5959
1. Optionally select one or more products to associate with the API. Select **Next**.
60-
1. On the **Policies** tab, optionally enable policies to monitor and manage Azure OpenAI API token consumption.
61-
If selected, enter settings or accept defaults that define the `azure-openai-token-limit` and `azure-openai-emit-token-metric` policies for your API. You can also set or update the policy configuration later. Select **Review + Create**.
60+
1. On the **Policies** tab, optionally enable policies to monitor and manage Azure OpenAI API token consumption and response caching. You can also set or edit policies later.
61+
62+
If selected, enter settings or accept defaults that define the following policies (see linked articles for configuration details):
63+
* [Manage token consumption](azure-openai-token-limit-policy.md)
64+
* [Track token usage](azure-openai-emit-token-metric-policy.md)
65+
* [Enable semantic caching](azure-openai-enable-semantic-caching.md)
66+
67+
Select **Review + Create**.
6268
1. After settings are validated, select **Create**.
6369

6470
## Option 2. Add an OpenAPI specification to API Management
@@ -67,7 +73,7 @@ Alternatively, manually download the OpenAPI specification for the Azure OpenAI
6773

6874
### Download the OpenAPI specification
6975

70-
Download the OpenAPI specification for the Azure OpenAI REST API, such as the [2024-02-01 GA version](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-02-01/inference.json).
76+
Download the OpenAPI specification for the Azure OpenAI REST API, such as the [2024-10-01 GA version](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-10-01/inference.json).
7177

7278
1. In a text editor, open the specification file that you downloaded.
7379
1. In the `servers` element in the specification, substitute the name of your Azure OpenAI Service endpoint in the placeholder values of `url` and `default` endpoint in the specification. For example, if your Azure OpenAI Service endpoint is `contoso.openai.azure.com`, update the `servers` element with the following values:
@@ -89,7 +95,7 @@ Download the OpenAPI specification for the Azure OpenAI REST API, such as the [2
8995
],
9096
[...]
9197
```
92-
1. Make a note of the value of the API `version` in the specification. You'll need it to test the API. Example: `2024-02-01`.
98+
1. Make a note of the value of the API `version` in the specification. You'll need it to test the API. Example: `2024-10-01`.
9399

94100
### Add OpenAPI specification to API Management
95101

articles/api-management/backends.md

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: api-management
55
author: dlepow
66
ms.service: azure-api-management
77
ms.topic: concept-article
8-
ms.date: 05/13/2024
8+
ms.date: 01/24/2025
99
ms.author: danlep
1010
ms.custom:
1111
- build-2024
@@ -20,7 +20,7 @@ A *backend* (or *API backend*) in API Management is an HTTP service that impleme
2020
When importing certain APIs, API Management configures the API backend automatically. For example, API Management configures the backend web service when importing:
2121
* An [OpenAPI specification](import-api-from-oas.md).
2222
* A [SOAP API](import-soap-api.md).
23-
* Azure resources, such as an HTTP-triggered [Azure Function App](import-function-app-as-api.md) or [Logic App](import-logic-app-as-api.md).
23+
* Azure resources, such as An [Azure OpenAI API](azure-openai-api-from-specification.md), an HTTP-triggered [Azure Function App](import-function-app-as-api.md), or [Logic App](import-logic-app-as-api.md).
2424

2525
API Management also supports using other Azure resources as an API backend, such as:
2626
* A [Service Fabric cluster](how-to-configure-service-fabric-backend.yml).
@@ -39,9 +39,29 @@ Use backends for one or more of the following:
3939

4040
Configure and manage backend entities in the Azure portal, or using Azure APIs or tools.
4141

42+
## Create a backend
43+
44+
You can create a backend in the Azure portal, or using Azure APIs or tools.
45+
46+
To create a backend in the portal:
47+
48+
1. Sign into the [portal](https://portal.azure.com) and go to your API Management instance.
49+
1. In the left menu, select **APIs** > **Backends** > **+ Create new backend**.
50+
1. On the **Backend** page, do the following:
51+
1. Enter a **Name** for the backend and optional **Description**.
52+
1. Select a **Backend hosting type**, for example, **Azure resource** for an Azure resource such as a Function App or Logic App, **Custom URL** for a custom service, or a **Service Fabric** cluster.
53+
1. In **Runtime URL**, enter the URL of the backend service that API requests are forwarded to.
54+
1. Under **Advanced**, optionally disable certificate chain or certificate name validation for the backend.
55+
1. Under **Add this backend service to a backend pool**, optionally select or create a [load-balanced pool](#load-balanced-pool) for the backend.
56+
1. Under **Circuit breaker rule**, optionally configure a [circuit breaker](#circuit-breaker) for the backend.
57+
1. Under **Authorization credentials**, optionally configure credentials to authorize access to the backend. Options include a request header, query parameter, [client certificate](api-management-howto-mutual-certificates-for-clients.md), or system-assigned or user-assigned [managed identity](api-management-howto-use-managed-service-identity.md) configured in the API Management instance.
58+
1. Select **Create**.
59+
60+
After creating a backend, you can update the backend settings at any time. For example, add a circuit breaker rule, change the runtime URL, or add authorization credentials.
61+
4262
## Reference backend using set-backend-service policy
4363

44-
After creating a backend, you can reference the backend in your APIs. Use the [`set-backend-service`](set-backend-service-policy.md) policy to direct an incoming API request to the backend. If you already configured a backend web service for an API, you can use the `set-backend-service` policy to redirect the request to a backend entity instead. For example:
64+
After creating a backend, you can reference the backend identifier (name) in your APIs. Use the [`set-backend-service`](set-backend-service-policy.md) policy to direct an incoming API request to the backend. If you already configured a backend web service for an API, you can use the `set-backend-service` policy to redirect the request to a backend entity instead. For example:
4565

4666
```xml
4767
<policies>
@@ -93,9 +113,22 @@ The backend circuit breaker is an implementation of the [circuit breaker pattern
93113
94114
### Example
95115

96-
Use the API Management [REST API](/rest/api/apimanagement/backend) or a Bicep or ARM template to configure a circuit breaker in a backend. In the following example, the circuit breaker in *myBackend* in the API Management instance *myAPIM* trips when there are three or more `5xx` status codes indicating server errors in 1 hour.
116+
Use the Azure portal, API Management [REST API](/rest/api/apimanagement/backend), or a Bicep or ARM template to configure a circuit breaker in a backend. In the following example, the circuit breaker in *myBackend* in the API Management instance *myAPIM* trips when there are three or more `5xx` status codes indicating server errors in 1 hour.
97117

98-
The circuit breaker resets after 1 hour. If a `Retry-After` header is present in the response, the circuit breaker accepts the value and waits for the specified time before sending requests to the backend again.
118+
The circuit breaker in this example resets after 1 hour. If a `Retry-After` header is present in the response, the circuit breaker accepts the value and waits for the specified time before sending requests to the backend again.
119+
120+
#### [Portal](#tab/portal)
121+
122+
1. In the [Azure portal](https://portal.azure.com), go to your API Management instance.
123+
1. In the left menu, select **APIs** > **Backends** > your backend.
124+
1. In the backend page, select **Settings** > **Circuit breaker settings** > **Add new**.
125+
1. In the **Create new circuit breaker** page, configure the rule:
126+
* **Rule name**: Enter a name for the rule, such as *myBackend*.
127+
* **Failure count**: Enter *3*.
128+
* **Failure interval**: Leave the default value of **1 hour**.
129+
* **Failure status code range**: Select **500 - 599**.
130+
* **Trip duration**: Leave the default value of **1 hour**.
131+
* **Check 'Retry-After' header in HTTP response**: Select **True (Accept)**.
99132

100133
#### [Bicep](#tab/bicep)
101134

@@ -173,17 +206,16 @@ Include a JSON snippet similar to the following in your ARM template for a backe
173206

174207
## Load-balanced pool
175208

176-
API Management supports backend *pools*, when you want to implement multiple backends for an API and load-balance requests across those backends.
209+
API Management supports backend *pools*, when you want to implement multiple backends for an API and load-balance requests across those backends. A pool is a collection of backends that are treated as a single entity for load balancing.
177210

178211
Use a backend pool for scenarios such as the following:
179212

180213
* Spread the load to multiple backends, which may have individual backend circuit breakers.
181214
* Shift the load from one set of backends to another for upgrade (blue-green deployment).
182215

183-
To create a backend pool, set the `type` property of the backend to `pool` and specify a list of backends that make up the pool.
184216

185217
> [!NOTE]
186-
> * Currently, you can only include single backends in a backend pool. You can't add a backend of type `pool` to another backend pool. You can include up to 30 backends in a pool.
218+
> * You can include up to 30 backends in a pool.
187219
> * Because of the distributed nature of the API Management architecture, backend load balancing is approximate. Different instances of the gateway do not synchronize and will load balance based on the information on the same instance.
188220
189221

@@ -200,11 +232,25 @@ API Management supports the following load balancing options for backend pools:
200232
201233
### Example
202234

203-
Use the API Management [REST API](/rest/api/apimanagement/backend) or a Bicep or ARM template to configure a backend pool. In the following example, the backend *myBackendPool* in the API Management instance *myAPIM* is configured with a backend pool. Example backends in the pool are named *backend-1* and *backend-2*. Both backends are in the highest priority group; within the group, *backend-1* has a greater weight than *backend-2* .
235+
Use the portal, API Management [REST API](/rest/api/apimanagement/backend), or a Bicep or ARM template to configure a backend pool. In the following example, the backend *myBackendPool* in the API Management instance *myAPIM* is configured with a backend pool. Example backends in the pool are named *backend-1* and *backend-2*. Both backends are in the highest priority group; within the group, *backend-1* has a greater weight than *backend-2* .
236+
237+
238+
#### [Portal](#tab/portal)
239+
240+
1. In the [Azure portal](https://portal.azure.com), go to your API Management instance.
241+
1. In the left menu, select **APIs** > **Backends** > your backend.
242+
1. In the **Backends** page, select the **Load balancer** tab.
243+
1. Select **+ Create new pool**.
244+
1. In the **Create new load-balanced pool** page, do the following:
245+
* **Name**: Enter a name for the pool such as *myBackendPool*.
246+
* **Description**: Optionally enter a description.
247+
* **Add backends to pool**: Select one or more backends to add to the pool.
248+
* **Backend weight and priority**: Select **Customize weight and priority** to configure the weight and priority of each backend in the pool. For example, if you added two backends named *backend-1* and *backend-2*, set the weight of *backend-1* to 3 and the weight of *backend-2* to 1, and set the priority of both backends to 1.
249+
* Select **Create**.
204250

205251
#### [Bicep](#tab/bicep)
206252

207-
Include a snippet similar to the following in your Bicep template for a backend resource with a load-balanced pool:
253+
Include a snippet similar to the following in your Bicep template for a load-balanced pool. Set the `type` property of the backend entity to `Pool` and specify the backends in the pool:
208254

209255
```bicep
210256
resource symbolicname 'Microsoft.ApiManagement/service/backends@2023-09-01-preview' = {
@@ -231,7 +277,7 @@ resource symbolicname 'Microsoft.ApiManagement/service/backends@2023-09-01-previ
231277
```
232278
#### [ARM](#tab/arm)
233279

234-
Include a JSON snippet similar to the following in your ARM template for a backend resource with a load-balanced pool.
280+
Include a JSON snippet similar to the following in your ARM template for a load-balanced pool. Set the `type` property of the backend resource to `Pool` and specify the backends in the pool:
235281

236282
```json
237283
{

0 commit comments

Comments
 (0)