Skip to content

Commit cb82017

Browse files
authored
Merge pull request #297478 from MicrosoftDocs/main
4/1/2025 PM Publish
2 parents ce80e61 + 5532224 commit cb82017

File tree

220 files changed

+1229
-14735
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+1229
-14735
lines changed

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

Lines changed: 4 additions & 1 deletion
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: concept-article
8-
ms.date: 01/23/2025
8+
ms.date: 04/01/2025
99
ms.author: danlep
1010
ms.collection: ce-skilling-ai-copilot
1111
---
@@ -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: 24 additions & 15 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: 01/23/2025
8+
ms.date: 04/01/2025
99
ms.collection: ce-skilling-ai-copilot
1010
ms.custom: template-how-to, build-2024
1111
---
@@ -29,6 +29,10 @@ Learn more about managing AI APIs in API Management:
2929
- An Azure OpenAI resource with a model deployed. For more information about model deployment, see the [resource deployment guide](/azure/ai-services/openai/how-to/create-resource).
3030

3131
Make a note of the ID (name) of the deployment. You'll need it when you test the imported API in API Management.
32+
33+
> [!NOTE]
34+
> API Management policies such as [azure-openai-token-limit](azure-openai-token-limit-policy.md) and [azure-openai-emit-token-metric](azure-openai-emit-token-metric-policy.md) are supported for certain API endpoints exposed through specific Azure OpenAI Service models. For more information, see [Supported Azure OpenAI Service models](azure-openai-token-limit-policy.md#supported-azure-openai-service-models).
35+
3236
- Permissions to grant access to the Azure OpenAI resource from the API Management instance.
3337

3438
## Option 1. Import API from Azure OpenAI Service
@@ -39,11 +43,11 @@ You can import an Azure OpenAI API directly from Azure OpenAI Service to API Man
3943

4044
When you import the API, API Management automatically configures:
4145

42-
* Operations for each of the Azure OpenAI [REST API endpoints](/azure/ai-services/openai/reference).
46+
* Operations for each of the Azure OpenAI [REST API endpoints](/azure/ai-services/openai/reference)
4347
* A system-assigned identity with the necessary permissions to access the Azure OpenAI resource.
44-
* 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.
45-
* 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.
46-
* (optionally) Policies to help you monitor and manage token consumption by the Azure OpenAI API.
48+
* 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.
49+
* Authentication to the Azure OpenAI backend using the instance's system-assigned managed identity.
50+
* (optionally) Policies to help you monitor and manage the Azure OpenAI API.
4751

4852
To import an Azure OpenAI API to API Management:
4953

@@ -55,14 +59,19 @@ To import an Azure OpenAI API to API Management:
5559

5660
1. On the **Basics** tab:
5761
1. Select the Azure OpenAI resource that you want to import.
58-
1. Optionally select an **Azure OpenAI API version**. If you don't select one, the latest production-ready REST API version is used by default.
62+
1. Optionally select an **Azure OpenAI API version**. If you don't select one, the latest production-ready REST API version is used by default. Make a note of the version you selected. You'll need it to test the API.
5963
1. Enter a **Display name** and optional **Description** for the API.
6064
1. In **Base URL**, append a path that your API Management instance uses to access the Azure OpenAI API endpoints. If you enable **Ensure OpenAI SDK compatibility** (recommended), `/openai` is automatically appended to the base URL.
6165

6266
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`.
6367
1. Optionally select one or more products to associate with the API. Select **Next**.
64-
1. On the **Policies** tab, optionally enable policies to monitor and manage Azure OpenAI API token consumption.
65-
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**.
68+
1. On the **Policies** tab, optionally enable policies to monitor and manage Azure OpenAI API token consumption. You can also set or edit policies later.
69+
70+
If selected, enter settings or accept defaults that define the following policies (see linked articles for prerequisites and configuration details):
71+
* [Manage token consumption](azure-openai-token-limit-policy.md)
72+
* [Track token usage](azure-openai-emit-token-metric-policy.md)
73+
74+
Select **Review + Create**.
6675
1. After settings are validated, select **Create**.
6776

6877
## Option 2. Add an OpenAPI specification to API Management
@@ -71,13 +80,13 @@ Alternatively, manually download the OpenAPI specification for the Azure OpenAI
7180

7281
### Download the OpenAPI specification
7382

74-
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).
83+
Download the OpenAPI specification for the Azure OpenAI REST API, such as the [2024-10-21 GA version](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-10-21/inference.json).
7584

7685
1. In a text editor, open the specification file that you downloaded.
7786
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:
7887

79-
* url: `https://contoso.openai.azure.com/openai`
80-
* default endpoint: `contoso.openai.azure.com`
88+
* **url**: `https://contoso.openai.azure.com/openai`
89+
* **default** endpoint: `contoso.openai.azure.com`
8190

8291
```json
8392
[...]
@@ -93,7 +102,7 @@ Download the OpenAPI specification for the Azure OpenAI REST API, such as the [2
93102
],
94103
[...]
95104
```
96-
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`.
105+
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-21`.
97106

98107
### Add OpenAPI specification to API Management
99108

@@ -113,7 +122,7 @@ If you added the Azure OpenAI API from its OpenAPI specification, you need to co
113122

114123
## Test the Azure OpenAI API
115124

116-
To ensure that your Azure OpenAI API is working as expected, test it in the API Management test console. You need to supply a model deployment ID (name) configured in the Azure OpenAI resource to test the API.
125+
To ensure that your Azure OpenAI API is working as expected, test it in the API Management test console. You need to supply a model deployment ID (name) configured in the Azure OpenAI resource and the API version to test the API.
117126

118127
1. Select the API you created in the previous step.
119128
1. Select the **Test** tab.
@@ -128,7 +137,8 @@ To ensure that your Azure OpenAI API is working as expected, test it in the API
128137
> In the test console, API Management automatically populates an **Ocp-Apim-Subscription-Key** header, and configures the subscription key of the built-in [all-access subscription](api-management-subscriptions.md#all-access-subscription). This key enables access to every API in the API Management instance. Optionally display the **Ocp-Apim-Subscription-Key** header by selecting the "eye" icon next to the **HTTP Request**.
129138
1. Select **Send**.
130139

131-
When the test is successful, the backend responds with a successful HTTP response code and some data. Appended to the response is token usage data to help you monitor and manage your Azure OpenAI API consumption.
140+
When the test is successful, the backend responds with a successful HTTP response code and some data. Appended to the response is token usage data to help you monitor and manage your Azure OpenAI API token consumption.
141+
132142
:::image type="content" source="media/azure-openai-api-from-specification/api-response-usage.png" alt-text="Screenshot of token usage data in API response in the portal." :::
133143

134144
## Caching policies for Azure OpenAI APIs
@@ -138,5 +148,4 @@ In addition to the `azure-openai-token-limit` and `azure-openai-emit-token-metri
138148
* `azure-openai-semantic-cache-store`
139149
* `azure-openai-semantic-cache-lookup`
140150

141-
142151
[!INCLUDE [api-management-define-api-topics.md](../../includes/api-management-define-api-topics.md)]

articles/api-management/azure-openai-emit-token-metric-policy.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: dlepow
66

77
ms.service: azure-api-management
88
ms.topic: reference
9-
ms.date: 09/26/2024
9+
ms.date: 04/01/2025
1010
ms.author: danlep
1111
ms.collection: ce-skilling-ai-copilot
1212
ms.custom:
@@ -65,19 +65,11 @@ The `azure-openai-emit-token-metric` policy sends custom metrics to Application
6565
| name | A string or policy expression. Name of dimension. | Yes | N/A |
6666
| value | A string or policy expression. Value of dimension. Can only be omitted if `name` matches one of the default dimensions. If so, value is provided as per dimension name. | No | N/A |
6767

68-
### Default dimension names that may be used without value
69-
70-
* API ID
71-
* Operation ID
72-
* Product ID
73-
* User ID
74-
* Subscription ID
75-
* Location
76-
* Gateway ID
68+
[!INCLUDE [api-management-emit-metric-dimensions](../../includes/api-management-emit-metric-dimensions.md)]
7769

7870
## Usage
7971

80-
- [**Policy sections:**](./api-management-howto-policies.md#sections) inbound
72+
- [**Policy sections:**](./api-management-howto-policies.md#sections) inbound, outbound
8173
- [**Policy scopes:**](./api-management-howto-policies.md#scopes) global, workspace, product, API, operation
8274
- [**Gateways:**](api-management-gateways-overview.md) classic, v2, consumption, self-hosted, workspace
8375

@@ -91,7 +83,7 @@ The `azure-openai-emit-token-metric` policy sends custom metrics to Application
9183

9284
## Example
9385

94-
The following example sends Azure OpenAI token count metrics to Application Insights along with API ID as a custom dimension.
86+
The following example sends Azure OpenAI token count metrics to Application Insights along with API ID as a default dimension.
9587

9688
```xml
9789
<policies>

0 commit comments

Comments
 (0)