Skip to content

Commit 37bbf81

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/azure-docs-pr (branch live)
2 parents 8ddd515 + 2032527 commit 37bbf81

File tree

214 files changed

+776
-576
lines changed

Some content is hidden

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

214 files changed

+776
-576
lines changed

.github/policies/disallow-edits.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,16 @@ configuration:
155155
if:
156156
# If a 'sign-off' comment is added to a PR in the articles/reliability folder , and the PR author isn't Anastasia or John...
157157
- payloadType: Issue_Comment
158-
- isPullRequest
159158
- filesMatchPattern:
160159
matchAny: true
161160
pattern: articles/reliability/*
162-
- commentContains:
163-
pattern: '\#sign-off'
164-
isRegex: true
161+
- or:
162+
- commentContains:
163+
pattern: ^(#sign-off)$
164+
isRegex: True
165+
- commentContains:
166+
pattern: ^(\#sign-off)$
167+
isRegex: True
165168
- not:
166169
or:
167170
- isActivitySender:

.openpublishing.redirection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@
200200
"redirect_url": "https://azuremarketplace.microsoft.com/marketplace/apps?page=1",
201201
"redirect_document_id": false
202202
},
203+
{
204+
"source_path": "articles/partner-solutions/logzio/index.yml",
205+
"redirect_url": "/previous-versions/azure/partner-solutions/logzio/index",
206+
"redirect_document_id": false
207+
},
203208
{
204209
"source_path": "articles/partner-solutions/logzio/create.md",
205210
"redirect_url": "/previous-versions/azure/partner-solutions/logzio/create",

articles/api-management/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,8 @@
544544
href: json-to-xml-policy.md
545545
- name: limit-concurrency
546546
href: limit-concurrency-policy.md
547+
- name: llm-content-safety
548+
href: llm-content-safety-policy.md
547549
- name: llm-emit-token-metric
548550
href: llm-emit-token-metric-policy.md
549551
- name: llm-semantic-cache-lookup

articles/api-management/api-management-policies.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ More information about policies:
5959

6060
|Policy |Description | Classic | V2 | Consumption |Self-hosted |Workspace |
6161
|---------|---------|---------|---------|---------|--------|------|
62+
| [Enforce content safety checks on LLM requests](llm-content-safety-policy.md) | Enforces content safety checks on LLM requests (prompts) by transmitting them to the [Azure AI Content Safety](/azure/ai-services/content-safety/overview) service before sending to the backend LLM. | Yes | Yes | Yes | Yes | Yes |
6263
| [Validate content](validate-content-policy.md) | Validates the size or content of a request or response body against one or more API schemas. The supported schema formats are JSON and XML. | Yes | Yes | Yes | Yes | Yes |
6364
| [Validate GraphQL request](validate-graphql-request-policy.md) | Validates and authorizes a request to a GraphQL API. | Yes | Yes | Yes | Yes | No |
6465
| [Validate OData request](validate-odata-request-policy.md) | Validates a request to an OData API to ensure conformance with the OData specification. | Yes | Yes | Yes | Yes | Yes |
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
title: Azure API Management policy reference - llm-content-safety
3+
description: Reference for the llm-content-safety policy available for use in Azure API Management. Provides policy usage, settings, and examples.
4+
services: api-management
5+
author: dlepow
6+
7+
ms.service: azure-api-management
8+
ms.collection: ce-skilling-ai-copilot
9+
ms.custom:
10+
ms.topic: article
11+
ms.date: 03/04/2025
12+
ms.author: danlep
13+
---
14+
15+
# Enforce content safety checks on LLM requests
16+
17+
[!INCLUDE [api-management-availability-premium-dev-standard-basic-premiumv2-standardv2-basicv2](../../includes/api-management-availability-premium-dev-standard-basic-premiumv2-standardv2-basicv2.md)]
18+
19+
The `llm-content-safety` policy enforces content safety checks on large language model (LLM) requests (prompts) by transmitting them to the [Azure AI Content Safety](/azure/ai-services/content-safety/overview) service before sending to the backend LLM API. When the policy is enabled and Azure AI Content Safety detects malicious content, API Management blocks the request and returns a `403` error code.
20+
21+
Use the policy in scenarios such as the following:
22+
23+
* Block requests that contain predefined categories of harmful content or hate speech
24+
* Apply custom blocklists to prevent specific content from being sent
25+
* Shield against prompts that match attack patterns
26+
27+
[!INCLUDE [api-management-policy-generic-alert](../../includes/api-management-policy-generic-alert.md)]
28+
29+
## Prerequisites
30+
31+
* An [Azure AI Content Safety](/azure/ai-services/content-safety/) resource.
32+
* An API Management [backend](backends.md) configured to route content safety API calls and authenticate to the Azure AI Content Safety service, in the form `https://<content-safety-service-name>.cognitiveservices.azure.com`. Managed identity with Cognitive Services User role is recommended for authentication.
33+
34+
35+
## Policy statement
36+
37+
```xml
38+
<llm-content-safety backend-id="name of backend entity" shield-prompt="true | false" >
39+
<categories output-type="FourSeverityLevels | EightSeverityLevels">
40+
<category name="Hate | SelfHarm | Sexual | Violence" threshold="integer" />
41+
<!-- If there are multiple categories, add more category elements -->
42+
[...]
43+
</categories>
44+
<blocklists>
45+
<id>blocklist-identifier</id>
46+
<!-- If there are multiple blocklists, add more id elements -->
47+
[...]
48+
</blocklists>
49+
</llm-content-safety>
50+
```
51+
52+
## Attributes
53+
54+
| Attribute | Description | Required | Default |
55+
| -------------- | ----------------------------------------------------------------------------------------------------- | -------- | ------- |
56+
| backend-id | Identifier (name) of the Azure AI Content Safety backend to route content-safety API calls to. Policy expressions are allowed. | Yes | N/A |
57+
| shield-prompt | If set to `true`, content is checked for user attacks. Otherwise, skip this check. Policy expressions are allowed. | No | `false` |
58+
59+
60+
## Elements
61+
62+
| Element | Description | Required |
63+
| -------------- | -----| -------- |
64+
| categories | A list of `category` elements that specify settings for blocking requests when the category is detected. | No |
65+
| blocklists | A list of [blocklist](/azure/ai-services/content-safety/how-to/use-blocklist) `id` elements from the Azure AI Content Safety instance for which detection causes the request to be blocked. Policy expressions are allowed. | No |
66+
67+
### categories attributes
68+
69+
| Attribute | Description | Required | Default |
70+
| -------------- | ----------------------------------------------------------------------------------------------------- | -------- | ------- |
71+
| output-type | Specifies how severity levels are returned by Azure AI Content Safety. The attribute must have one of the following values.<br /><br />- `FourSeverityLevels`: Output severities in four levels: 0,2,4,6.<br/>- `EightSeverityLevels`: Output severities in eight levels: 0,1,2,3,4,5,6,7.<br/><br/>Policy expressions are allowed. | No | `FourSeverityLevels` |
72+
73+
74+
### category attributes
75+
76+
| Attribute | Description | Required | Default |
77+
| -------------- | ----------------------------------------------------------------------------------------------------- | -------- | ------- |
78+
| name | Specifies the name of this category. The attribute must have one of the following values: `Hate`, `SelfHarm`, `Sexual`, `Violence`. Policy expressions are allowed. | Yes | N/A |
79+
| threshold | Specifies the threshold value for this category at which request are blocked. Requests with content severities less than the threshold aren't blocked. The value must be between 0 and 7. Policy expressions are allowed. | Yes | N/A |
80+
81+
82+
## Usage
83+
84+
- [**Policy sections:**](./api-management-howto-policies.md#sections) inbound
85+
- [**Policy scopes:**](./api-management-howto-policies.md#scopes) global, workspace, product, API
86+
- [**Gateways:**](api-management-gateways-overview.md) classic, v2, consumption, self-hosted, workspace
87+
88+
### Usage notes
89+
90+
* The policy runs on a concatenation of all text content in a completion or chat completion request.
91+
* If the request exceeds the character limit of Azure AI Content Safety, a `403` error is returned.
92+
* This policy can be used multiple times per policy definition.
93+
94+
## Example
95+
96+
The following example enforces content safety checks on LLM requests using the Azure AI Content Safety service. The policy blocks requests that contain speech in the `Hate` or `Violence` category with a severity level of 4 or higher. The `shield-prompt` attribute is set to `true` to check for adversarial attacks.
97+
98+
```xml
99+
<policies>
100+
<inbound>
101+
<llm-content-safety backend-id="content-safety-backend" shield-prompt="true">
102+
<categories output-type="EightSeverityLevels">
103+
<category name="Hate" threshold="4" />
104+
<category name="Violence" threshold="4" />
105+
</categories>
106+
</llm-content-safety>
107+
</inbound>
108+
</policies>
109+
110+
```
111+
112+
## Related policies
113+
114+
* [Content validation](api-management-policies.md#content-validation)
115+
* [llm-token-limit](llm-token-limit-policy.md) policy
116+
* [llm-emit-token-metric](llm-emit-token-metric-policy.md) policy
117+
118+
[!INCLUDE [api-management-policy-ref-next-steps](../../includes/api-management-policy-ref-next-steps.md)]

articles/application-gateway/configuration-infrastructure.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,11 @@ Depending on whether you're creating new resources or using existing ones, add t
8383

8484
|Resource | Resource status | Required Azure permissions |
8585
|---|---|---|
86-
| Subnet | Create new| Microsoft.Network/virtualNetworks/subnets/write<br>Microsoft.Network/virtualNetworks/subnets/join/action |
87-
| Subnet | Use existing| Microsoft.Network/virtualNetworks/subnets/read<br>Microsoft.Network/virtualNetworks/subnets/join/action |
88-
| IP addresses| Create new| Microsoft.Network/publicIPAddresses/write<br>Microsoft.Network/publicIPAddresses/join/action |
89-
| IP addresses | Use existing| Microsoft.Network/publicIPAddresses/read<br>Microsoft.Network/publicIPAddresses/join/action |
90-
| ApplicationGatewayWebApplicationFirewallPolicies | Create new / Update existing | Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/write
91-
Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/read
92-
Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/join/action |
86+
| Subnet | Create new| `Microsoft.Network/virtualNetworks/subnets/write' <br> 'Microsoft.Network/virtualNetworks/subnets/join/action` |
87+
| Subnet | Use existing| `Microsoft.Network/virtualNetworks/subnets/read` <br> `Microsoft.Network/virtualNetworks/subnets/join/action` |
88+
| IP addresses| Create new| `Microsoft.Network/publicIPAddresses/write` <br> `Microsoft.Network/publicIPAddresses/join/action` |
89+
| IP addresses | Use existing| `Microsoft.Network/publicIPAddresses/read` <br> `Microsoft.Network/publicIPAddresses/join/action` |
90+
| ApplicationGatewayWebApplicationFirewallPolicies | Create new / Update existing | `Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/write` <br> `Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/read` <br> `Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/join/action` |
9391

9492
For more information, see [Azure permissions for Networking](../role-based-access-control/permissions/networking.md) and [Virtual network permissions](../virtual-network/virtual-network-manage-subnet.md#permissions).
9593
## Roles scope

articles/azure-cache-for-redis/cache-best-practices-client-libraries.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ For information on client library-specific guidance best practices, see the foll
3434

3535
- [StackExchange.Redis (.NET)](cache-best-practices-connection.md#using-forcereconnect-with-stackexchangeredis)
3636
- [Lettuce (Java)](https://github.com/Azure/AzureCacheForRedis/blob/main/Lettuce%20Best%20Practices.md)
37-
- [Jedis (Java)](https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#file-redis-bestpractices-java-jedis-md)
37+
- [Jedis (Java)](https://github.com/Azure/AzureCacheForRedis/blob/main/Redis-BestPractices-Java-Jedis.md)
3838
- [Redisson (Java)](cache-best-practices-client-libraries.md#redisson-java)
39-
- [Node.js](https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#file-redis-bestpractices-node-js-md)
40-
- [PHP](https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#file-redis-bestpractices-php-md)
39+
- [Node.js](https://github.com/Azure/AzureCacheForRedis/blob/main/Redis-BestPractices-Node-js.md)
40+
- [PHP](https://github.com/Azure/AzureCacheForRedis/blob/main/Redis-BestPractices-PHP.md)
4141
- [HiRedisCluster](https://github.com/Azure/AzureCacheForRedis/blob/main/HiRedisCluster%20Best%20Practices.md)
42-
- [ASP.NET Session State Provider](https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#file-redis-bestpractices-session-state-provider-md)
4342

4443
## Redisson (Java)
4544

articles/azure-cache-for-redis/cache-redis-samples.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ description: 'Learn how to use Azure Cache for Redis with these code samples: co
66

77
ms.custom:
88
ms.topic: sample
9-
ms.date: 05/11/2021
9+
ms.date: 03/04/2025
1010
---
1111
# Azure Cache for Redis samples
1212

13-
You'll find a list of Azure Cache for Redis samples in this article.
13+
You'll find a list of Azure Redis samples in this article.
1414
The samples cover scenarios such as:
1515

1616
* Connecting to a cache
1717
* Reading and writing data to and from a cache
1818
* And using the ASP.NET Azure Cache for Redis providers.
1919

20-
Some samples are downloadable projects. Other samples provide step-by-step guidance that includes code snippets but don't link to a downloadable project.
20+
Some samples are downloadable projects. Other samples provide step-by-step guidance that includes code snippets, but don't link to a downloadable project.
2121

2222
## Hello world samples
2323

articles/azure-cache-for-redis/managed-redis/managed-redis-architecture.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Azure Managed Redis offers two choices for clustering policy: _OSS_ and _Enterpr
4949

5050
The **OSS clustering policy** implements the same [Redis Cluster API](https://redis.io/docs/reference/cluster-spec/) as community edition Redis. The Redis Cluster API allows the Redis client to connect directly to shards on each Redis node, minimizing latency and optimizing network throughput, allowing throughput to scale near-linearly as the number of shards and vCPUs increases. The OSS clustering policy generally provides the best latency and throughput performance. The OSS cluster policy, however, requires your client library to support the Redis Cluster API. Today, almost all Redis clients support the Redis Cluster API, but compatibility might be an issue for older client versions or specialized libraries. OSS clustering policy also can't be used with the [RediSearch module](../cache-redis-modules.md).
5151

52+
The OSS clustering protocol requires the client to make the correct shard connections. The initial connection is through port 10000. Connecting to individual nodes is done using ports in the 85XX range. The 85xx ports will change over time and shouldn't be hardcoded into your application. Redis clients that support clustering use the [CLUSTER NODES](https://redis.io/commands/cluster-nodes/) command to determine the exact ports used for the primary and replica shards and make the shard connections for you.
53+
5254
The **Enterprise clustering policy** is a simpler configuration that utilizes a single endpoint for all client connections. Using the Enterprise clustering policy routes all requests to a single Redis node that is then used as a proxy, internally routing requests to the correct node in the cluster. The advantage of this approach is that it makes Azure Managed Redis look nonclustered to users. That means that Redis client libraries don’t need to support Redis Clustering to gain some of the performance advantages of Redis Enterprise, boosting backwards compatibility and making the connection simpler. The downside is that the single node proxy can be a bottleneck, in either compute utilization or network throughput. The Enterprise clustering policy is the only one that can be used with the [RediSearch module](../cache-redis-modules.md). While the Enterprise cluster policy makes an Azure Managed Redis instance appear to be nonclustered to users, it still has some limitations with [Multi-key commands](#multi-key-commands).
5355

5456
### Scaling out or adding nodes

articles/azure-cache-for-redis/managed-redis/managed-redis-best-practices-client-libraries.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,13 @@ In Active-Active databases, multi-key write commands (`DEL`, `MSET`, `UNLINK`) c
6363

6464
For information on client library-specific guidance best practices, see the following links:
6565

66-
- [StackExchange.Redis (.NET)](../cache-best-practices-connection.md#using-forcereconnect-with-stackexchangeredis)
66+
- [StackExchange.Redis (.NET)](managed-redis-best-practices-connection.md#using-forcereconnect-with-stackexchangeredis)
6767
- [Lettuce (Java)](https://github.com/Azure/AzureCacheForRedis/blob/main/Lettuce%20Best%20Practices.md)
68-
- [Jedis (Java)](https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#file-redis-bestpractices-java-jedis-md)
69-
- [Redisson (Java)](../cache-best-practices-client-libraries.md#redisson-java)
70-
- [Node.js](https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#file-redis-bestpractices-node-js-md)
71-
- [PHP](https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#file-redis-bestpractices-php-md)
68+
- [Jedis (Java)](https://github.com/Azure/AzureCacheForRedis/blob/main/Redis-BestPractices-Java-Jedis.md)
69+
- [Redisson (Java)](managed-redis-best-practices-client-libraries.md#redisson-java)
70+
- [Node.js](https://github.com/Azure/AzureCacheForRedis/blob/main/Redis-BestPractices-Node-js.md)
71+
- [PHP](https://github.com/Azure/AzureCacheForRedis/blob/main/Redis-BestPractices-PHP.md)
7272
- [HiRedisCluster](https://github.com/Azure/AzureCacheForRedis/blob/main/HiRedisCluster%20Best%20Practices.md)
73-
- [ASP.NET Session State Provider](https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#file-redis-bestpractices-session-state-provider-md)
7473

7574
## Redisson (Java)
7675

0 commit comments

Comments
 (0)