Skip to content

Commit c183890

Browse files
committed
Merge branch 'main' into reliability-bastion-edits
2 parents f019cfd + 1d08857 commit c183890

652 files changed

Lines changed: 12088 additions & 5204 deletions

File tree

Some content is hidden

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

.openpublishing.publish.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,12 @@
632632
"branch": "main",
633633
"branch_mapping": {}
634634
},
635+
{
636+
"path_to_root": "app-service-agentic-langgraph-foundry-python",
637+
"url": "https://github.com/Azure-Samples/app-service-agentic-langgraph-foundry-python",
638+
"branch": "main",
639+
"branch_mapping": {}
640+
},
635641
{
636642
"path_to_root": "app-service-agentic-semantic-kernel-java",
637643
"url": "https://github.com/Azure-Samples/app-service-agentic-semantic-kernel-java",

.openpublishing.redirection.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7152,7 +7152,17 @@
71527152
{
71537153
"source_path": "articles/reliability/migrate-storage.md",
71547154
"redirect_url": "/azure/storage/common/redundancy-migration",
7155+
"redirect_document_id": false
7156+
},
7157+
{
7158+
"source_path": "articles/reliability/reliability-operator-nexus.md",
7159+
"redirect_url": "/azure/reliability/overview-reliability-guidance",
7160+
"redirect_document_id": false
71557161
}
7162+
7163+
7164+
7165+
71567166
]
71577167
}
71587168

articles/active-directory-b2c/service-limits.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: CelesteDG
88
ms.service: azure-active-directory
99

1010
ms.topic: reference
11-
ms.date: 07/29/2025
11+
ms.date: 08/19/2025
1212
ms.subservice: b2c
1313
zone_pivot_groups: b2c-policy-type
1414

@@ -169,14 +169,20 @@ The following table lists the administrative configuration limits in the Azure A
169169
|Number of sign-out URLs per application  |1 |
170170
|String Limit per Attribute |250 Chars |
171171
|Number of B2C tenants per subscription |20 |
172-
|Total number of objects (user accounts and applications) per tenant (default limit)|1.25 million |
173-
|Total number of objects (user accounts and applications) per tenant (using a verified custom domain). If you want to increase this limit, please contact [Microsoft Support](find-help-open-support-ticket.md).|5.25 million |
172+
|Number of objects (user accounts and applications) per tenant (default limit) <sup>2</sup>|1.25 million|
173+
|Number of objects (user accounts and applications) per tenant (using a verified custom domain) <sup>3</sup>. If you want to increase this limit, please contact [Microsoft Support](find-help-open-support-ticket.md).|5.25 million|
174+
|Number of objects per tenant for Japan Go-Local Azure AD B2C tenants (default limit) <sup>4</sup>|310K|
175+
|Number of objects per tenant for Japan Go-Local Azure AD B2C tenants (using a verified custom domain) <sup>5</sup>. If you want to increase this limit, please contact [Microsoft Support](find-help-open-support-ticket.md).|570K|
174176
|Levels of [inheritance](custom-policy-overview.md#inheritance-model) in custom policies |10 |
175177
|Number of policies per Azure AD B2C tenant (user flows + custom policies) |200 |
176178
|Maximum policy file size |1024 KB |
177179
|Number of API connectors per tenant |20 |
178180

179-
<sup>1</sup> See also [Microsoft Entra service limits and restrictions](../active-directory/enterprise-users/directory-service-limits-restrictions.md).
181+
- <sup>1</sup> See also [Microsoft Entra service limits and restrictions](../active-directory/enterprise-users/directory-service-limits-restrictions.md).
182+
- <sup>2</sup> 1M user accounts and 250K applications.
183+
- <sup>3</sup> 5M user accounts and 250K applications.
184+
- <sup>4</sup> 60K user accounts and 250K applications.
185+
- <sup>5</sup> 320K user accounts and 250K applications.
180186

181187
## Region specific service limits
182188

articles/api-management/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@
252252
href: azure-openai-enable-semantic-caching.md
253253
- name: Authenticate and authorize to Azure OpenAI
254254
href: api-management-authenticate-authorize-azure-openai.md
255+
- name: Log LLM tokens, requests, and responses
256+
href: api-management-howto-llm-logs.md
255257
- name: Manage MCP servers
256258
items:
257259
- name: MCP server capabilities
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: Set Up Logging for LLM APIs in Azure API Management
3+
titleSuffix: Azure API Management
4+
description: Enable logging for LLM APIs in Azure API Management to track token usage, prompts, and completions for billing and auditing.
5+
#customer intent: As a system administrator, I want to enable logging of LLM request and response messages so that I can track API interactions for billing or auditing purposes.
6+
author: dlepow
7+
ms.service: azure-api-management
8+
ms.topic: how-to
9+
ms.date: 08/22/2025
10+
ms.author: danlep
11+
ai-usage: ai-assisted
12+
ms.collection: ce-skilling-ai-copilot
13+
ms.custom:
14+
---
15+
16+
# Log token usage, prompts, and completions for LLM APIs
17+
18+
In this article, you learn how to set up Azure Monitor logging for LLM API requests and responses in Azure API Management.
19+
20+
The API Management administrator can use LLM API request and response logs along with API Management gateway logs for scenarios such as the following:
21+
22+
* **Calculate usage for billing** - Calculate usage metrics for billing based on the number of tokens consumed by each application or API consumer (for example, segmented by subscription ID or IP address).
23+
24+
* **Inspect messages** - Inspect and analyze prompts and completions to help with debugging, auditing, and model evaluation.
25+
26+
Learn more about:
27+
28+
* [AI gateway capabilities in API Management](genai-gateway-capabilities.md)
29+
* [Monitoring API Management](monitor-api-management.md)
30+
31+
## Prerequisites
32+
- An Azure API Management instance.
33+
- A managed LLM chat completions API integrated with Azure API Management. For example, [Import an Azure AI Foundry API](azure-ai-foundry-api.md).
34+
- Access to an Azure Log Analytics workspace.
35+
- Appropriate permissions to configure diagnostic settings and access logs in API Management.
36+
37+
## Enable diagnostic setting for LLM API logs
38+
39+
Enable a diagnostic setting to log requests that the gateway processes for large language model REST APIs. For each request, Azure Monitor receives data about token usage (prompt tokens, completion tokens, and total tokens), the name of the model used, and optionally the request and response messages (prompt and completion). Large requests and responses are split into multiple log entries with sequence numbers for later reconstruction if needed.
40+
41+
The following are brief steps to enable a diagnostic setting that directs LLM API logs to a Log Analytics workspace. For more information, see [Enable diagnostic setting for Azure Monitor logs](monitor-api-management.md#enable-diagnostic-setting-for-azure-monitor-logs).
42+
43+
1. In the [Azure portal](https://portal.azure.com), navigate to your Azure API Management instance.
44+
1. In the left menu, under **Monitoring**, select **Diagnostic settings** > **+ Add diagnostic setting**.
45+
1. Configure the setting to send AI gateway logs to a Log Analytics workspace:
46+
- Under **Logs**, select **Logs related to generative AI gateway**.
47+
- Under **Destination details**, select **Send to Log Analytics workspace**.
48+
1. Review or configure other settings and make changes if needed.
49+
1. Select **Save**.
50+
51+
:::image type="content" source="media/api-management-howto-llm-logs/diagnostic-setting.png" alt-text="Screenshot of diagnostic setting for AI gateway logs in the portal.":::
52+
53+
## Enable logging of requests or responses for LLM API
54+
55+
You can enable diagnostic settings for all APIs or customize logging for specific APIs. The following are brief steps to log both LLM requests and response messages for an API. For more information, see [Modify API logging settings](monitor-api-management.md#modify-api-logging-settings).
56+
57+
1. In the left menu of your API Management instance, select **APIs > APIs** and then select the name of the API.
58+
1. Select the **Settings** tab from the top bar.
59+
1. Scroll down to the **Diagnostic Logs** section, and select the **Azure Monitor** tab.
60+
1. In **Log LLM messages**, select **Enabled**.
61+
1. Select **Log prompts** and enter a size in bytes, such as *32768*.
62+
1. Select **Log completions** and enter a size in bytes, such as *32768*.
63+
1. Review other settings and make changes if needed. Select **Save**.
64+
65+
:::image type="content" source="media/api-management-howto-llm-logs/enable-llm-api-logging.png" alt-text="Screenshot of enabling LLM logging for an API in the portal.":::
66+
67+
> [!NOTE]
68+
> If you enable collection, LLM request or response messages up to 32 KB in size are sent in a single entry. Messages larger than 32 KB are split and logged in 32 KB chunks with sequence numbers for later reconstruction. Request messages and response messages can't exceed 2 MB each.
69+
70+
71+
## Review analytics workbook for LLM APIs
72+
73+
The Azure Monitor-based **Analytics** dashboard provides insights into LLM API usage and token consumption using data aggregated in a Log Analytics workspace. [Learn more](monitor-api-management.md#get-api-analytics-in-azure-api-management) about Analytics in API Management.
74+
75+
1. In the left menu of your API Management instance, select **Monitoring** > **Analytics**.
76+
1. Select the **Language models** tab.
77+
1. Review metrics and visualizations for LLM API token consumption and requests in a selected **Time range**.
78+
79+
:::image type="content" source="media/api-management-howto-llm-logs/analytics-workbook-small.png" alt-text="Screenshot of analytics for language model APIs in the portal." lightbox="media/api-management-howto-llm-logs/analytics-workbook.png":::
80+
81+
## Review Azure Monitor logs for requests and responses
82+
83+
Review the [ApiManagementGatewayLlmLog](/azure/azure-monitor/reference/tables/apimanagementgatewayllmlog) log for details about LLM requests and responses, including token consumption, model deployment used, and other details over specific time ranges.
84+
85+
Requests and responses (including chunked messages for large requests and responses) appear in separate log entries that you can correlate by using the `CorrelationId` field.
86+
87+
For auditing purposes, use a Kusto query similar to the following query to join each request and response in a single record. Adjust the query to include the fields that you want to track.
88+
89+
```Kusto
90+
ApiManagementGatewayLlmLog
91+
| extend RequestArray = parse_json(RequestMessages)
92+
| extend ResponseArray = parse_json(ResponseMessages)
93+
| mv-expand RequestArray
94+
| mv-expand ResponseArray
95+
| project
96+
CorrelationId,
97+
RequestContent = tostring(RequestArray.content),
98+
ResponseContent = tostring(ResponseArray.content)
99+
| summarize
100+
Input = strcat_aray(make_list(RequestContent), " . "),
101+
Output = strcat_array(make_list(ResponseContent), " . ")
102+
by CorrelationId
103+
| where isnotempty(Input) and isnotempty(Output)
104+
```
105+
106+
:::image type="content" source="media/api-management-howto-llm-logs/llm-log-query-small.png" alt-text="Screenshot of query results for LLM logs in the portal." lightbox="media/api-management-howto-llm-logs/llm-log-query.png":::
107+
108+
## Upload data to Azure AI Foundry for model evaluation
109+
110+
You can export LLM logging data as a dataset for [model evaluation](/azure/ai-foundry/concepts/observability) in Azure AI Foundry. With model evaluation, you can assess the performance of your generative AI models and applications against a test model or dataset using built-in or custom evaluation metrics.
111+
112+
To use LLM logs as a dataset for model evaluation:
113+
114+
1. Join LLM request and response messages into a single record for each interaction, as shown in the [previous section](#review-azure-monitor-logs-for-requests-and-responses). Include the fields you want to use for model evaluation.
115+
1. Export the dataset to CSV format, which is compatible with Azure AI Foundry.
116+
1. In the Azure AI Foundry portal, create a new evaluation to upload and evaluate the dataset.
117+
118+
For details to create and run a model evaluation in Azure AI Foundry, see [Evaluate generative AI models and applications by using Azure AI Foundry](/azure/ai-foundry/how-to/evaluate-generative-ai-app).
119+
120+
## Related content
121+
122+
* [Learn more about monitoring API Management](monitor-api-management.md)
123+
* [Azure Monitor reference for API Management](monitor-api-management-reference.md)
124+
* [Tutorial: Monitor published APIs](api-management-howto-use-azure-monitor.md)

articles/api-management/genai-gateway-capabilities.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ In API Management, enable semantic caching by using Azure Redis Enterprise, Azur
109109
110110
## Logging token usage, prompts, and completions
111111

112-
Enable a [diagnostic setting](monitor-api-management.md#enable-diagnostic-setting-for-azure-monitor-logs) in your API Management instance to log requests processed by the gateway for large language model REST APIs. For each request, data is sent to Azure Monitor including token usage (prompt tokens, completion tokens, and total tokens), name of the model used, and optionally the request and response messages (prompt and completion). Large requests and responses are split into multiple log entries that are sequentially numbered for later reconstruction if needed.
112+
You can enable logging for requests processed by the gateway for large language model REST APIs. For each request, data is sent to Azure Monitor including token usage (prompt tokens, completion tokens, and total tokens), name of the model used, and optionally the request and response messages (prompt and completion). Large requests and responses are split into multiple log entries that are sequentially numbered for later reconstruction if needed.
113113

114114
The API Management administrator can use LLM gateway logs along with API Management gateway logs for scenarios such as the following:
115115

116116
* **Calculate usage for billing** - Calculate usage metrics for billing based on the number of tokens consumed by each application or API consumer (for example, segmented by subscription ID or IP address).
117117
* **Inspect messages** - To help with debugging or auditing, inspect and analyze prompts and completions.
118118

119-
Learn more about [monitoring API Management with Azure Monitor](monitor-api-management.md).
119+
Learn more: [Log token usage, prompts, and completions for LLM APIs](api-management-howto-llm-logs.md)
120120

121121
## Content safety policy
122122

@@ -135,7 +135,7 @@ To help safeguard users from harmful, offensive, or misleading content, you can
135135

136136
* [AI gateway reference architecture using API Management](/ai/playbook/technology-guidance/generative-ai/dev-starters/genai-gateway/reference-architectures/apim-based)
137137
* [AI hub gateway landing zone accelerator](https://github.com/Azure-Samples/ai-hub-gateway-solution-accelerator)
138-
* [Designing and implementing a gateway solution with Azure OpenAI resources](/ai/playbook/technology-guidance/generative-ai/dev-starters/genai-gateway/)
138+
* [Designing and implementing a gateway solution with Azure OpenAI resources](/ai/playbook/technology-guidance/generative-ai/dev-starters/gemonitoring API Management with Azurenai-gateway/)
139139
* [Use a gateway in front of multiple Azure OpenAI deployments or instances](/azure/architecture/ai-ml/guide/azure-openai-gateway-multi-backend)
140140

141141
## Related content
112 KB
Loading
112 KB
Loading
88.7 KB
Loading
69.6 KB
Loading

0 commit comments

Comments
 (0)