Skip to content

Commit 3d94973

Browse files
authored
Merge pull request #6190 from lgayhardt/redteamcloud0725
red teaming cloud update + include file for eval fdp
2 parents 415b6c3 + 72cb8e8 commit 3d94973

File tree

4 files changed

+66
-24
lines changed

4 files changed

+66
-24
lines changed

articles/ai-foundry/how-to/develop/cloud-evaluation.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ In this article, you learn how to run evaluations in the cloud (preview) in pre-
2828
- Azure OpenAI Deployment with GPT model supporting `chat completion`. For example, `gpt-4`.
2929
- Make sure you're first logged into your Azure subscription by running `az login`.
3030

31-
If this is your first time running evaluations and logging it to your Azure AI Foundry project, you might need to do a few additional steps:
32-
33-
1. Create and connect your storage account to your Azure AI Foundry project at the resource level. There are two ways you can do this. You can [use a Bicep template](https://github.com/azure-ai-foundry/foundry-samples/blob/main/samples/microsoft/infrastructure-setup/01-connections/connection-storage-account.bicep), which provisions and connects a storage account to your Foundry project with key authentication. You can also [manually create and provision access](../evaluations-storage-account.md) to your storage account in the Azure portal.
34-
1. Make sure the connected storage account has access to all projects.
35-
1. If you connected your storage account with Microsoft Entra ID, make sure to give managed identity **Storage Blob Data Owner** permissions to both your account and the Foundry project resource in the Azure portal.
31+
[!INCLUDE [evaluation-foundry-project-storage](../../includes/evaluation-foundry-project-storage.md)]
3632

3733
## Get started
3834

articles/ai-foundry/how-to/develop/run-ai-red-teaming-cloud.md

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: azure-ai-foundry
77
ms.custom:
88
- references_regions
99
ms.topic: how-to
10-
ms.date: 06/03/2025
10+
ms.date: 07/23/2025
1111
ms.reviewer: minthigpen
1212
ms.author: lagayhar
1313
author: lgayhardt
@@ -23,15 +23,11 @@ Though the AI Red Teaming Agent (preview) can be run [locally](run-scans-ai-red-
2323

2424
[!INCLUDE [uses-fdp-only](../../includes/uses-fdp-only.md)]
2525

26-
If this is your first time running evaluations or AI red teaming runs on your Azure AI Foundry project, you might need to do a few additional setup steps.
27-
28-
1. [Create and connect your storage account](https://github.com/azure-ai-foundry/foundry-samples/blob/main/samples/microsoft/infrastructure-setup/01-connections/connection-storage-account.bicep) to your Azure AI Foundry project at the resource level. This bicep template provisions and connects a storage account to your Foundry project with key authentication.
29-
2. Make sure the connected storage account has access to all projects.
30-
3. If you connected your storage account with Microsoft Entra ID, make sure to give MSI (Microsoft Identity) permissions for Storage Blob Data Owner to both your account and Foundry project resource in Azure portal.
26+
[!INCLUDE [evaluation-foundry-project-storage](../../includes/evaluation-foundry-project-storage.md)]
3127

3228
## Getting started
3329

34-
First, install Azure AI Foundry SDK's project client which runs the AI Red Teaming Agent in the cloud
30+
First, install Azure AI Foundry SDK's project client, which runs the AI Red Teaming Agent in the cloud.
3531

3632
```python
3733
uv install azure-ai-projects azure-identity
@@ -46,15 +42,44 @@ Then, set your environment variables for your Azure AI Foundry resources
4642
import os
4743

4844
endpoint = os.environ["PROJECT_ENDPOINT"] # Sample : https://<account_name>.services.ai.azure.com/api/projects/<project_name>
49-
model_endpoint = os.environ["MODEL_ENDPOINT"] # Sample : https://<account_name>.services.ai.azure.com
50-
model_api_key= os.environ["MODEL_API_KEY"]
51-
model_deployment_name = os.environ["MODEL_DEPLOYMENT_NAME"] # Sample : gpt-4o-mini
45+
5246
```
5347

5448
## Supported targets
5549

5650
Running the AI Red Teaming Agent in the cloud currently only supports Azure OpenAI model deployments in your Azure AI Foundry project as a target.
5751

52+
## Configure your target
53+
54+
You can configure your target model deployment in two ways:
55+
56+
### Option 1: Using Foundry project deployments
57+
58+
If you're using model deployments that are part of your Azure AI Foundry project, set up the following environment variables:
59+
60+
```python
61+
import os
62+
63+
model_endpoint = os.environ["MODEL_ENDPOINT"] # Sample : https://<account_name>.openai.azure.com
64+
model_api_key = os.environ["MODEL_API_KEY"]
65+
model_deployment_name = os.environ["MODEL_DEPLOYMENT_NAME"] # Sample : gpt-4o-mini
66+
```
67+
68+
### Option 2: Using Azure OpenAI/AI Services deployments
69+
70+
If you want to use deployments from your Azure OpenAI or AI Services accounts, you first need to connect these resources to your Foundry project through connections.
71+
72+
1. **Create a connection**: Follow the instructions in [Configure project connections](../../foundry-models/how-to/configure-project-connection.md?pivots=ai-foundry-portal#add-a-connection) to connect your Azure OpenAI or AI Services resource to your Foundry project.
73+
74+
2. **Get the connection name**: After connecting the account, you'll see the connection created with a generated name in your Foundry project.
75+
76+
3. **Configure the target**: Use the format `"connectionName/deploymentName"` for your model deployment configuration:
77+
78+
```python
79+
# Format: "connectionName/deploymentName"
80+
model_deployment_name = "my-openai-connection/gpt-4o-mini"
81+
```
82+
5883
## Create an AI red teaming run
5984

6085
# [Python](#tab/python)
@@ -86,19 +111,28 @@ red_team_agent = RedTeam(
86111
)
87112

88113
# Create and run the red teaming scan
89-
red_team_response = project_client.red_teams.create(red_team=red_team_agent, headers={"model-endpoint": model_endpoint, "api-key": model_api_key,})
114+
# If you configured target using Option 1, use:
115+
# headers = {"model-endpoint": model_endpoint, "api-key": model_api_key}
116+
# If you configured target using Option 2, use:
117+
# headers = {}
118+
119+
# Choose one of the following based on your configuration option:
120+
headers = {"model-endpoint": model_endpoint, "api-key": model_api_key} # For Option 1
121+
# headers = {} # For Option 2
122+
123+
red_team_response = project_client.red_teams.create(red_team=red_team_agent, headers=headers)
90124
```
91125

92126
# [cURL](#tab/curl)
93127

94128
```bash
95-
curl --request POST \ --url https://{{account}}.services.ai.azure.com/api/projects/{{project}}/redteams/runs:run \ --header 'content-type: application/json' \ --header 'authorization: Bearer {{ai_token}}' --data '{ "scanName": "sample_scan_magic_1", "riskCategories": [ "Violence" ], "attackStrategy": [ "Flip" ], "numTurns": 1, "target": { "type": "AzureOpenAIModel", "modelDeploymentName": "{{connectionName}}/{{deploymentName}}" }}'
129+
curl --request POST \ --url https://{{account}}.services.ai.azure.com/api/projects/{{project}}/redteams/runs:run \ --header 'content-type: application/json' \ --header 'authorization: Bearer {{ai_token}}' --data '{ "displayName": "Red Team Scan #1", "riskCategories": [ "Violence" ], "attackStrategy": [ "Flip" ], "numTurns": 1, "target": { "type": "AzureOpenAIModel", "modelDeploymentName": "{{connectionName}}/{{deploymentName}}" }}'
96130
```
97131

98132
- Replace `{{account}}`, `{{project}}` with Foundry Project account name and project name.
99133
- Replace `{{ai_token}}` with Bearer token with audience "<https://ai.azure.com>"
100-
- Replace `"{{connectionName}}"` with the Azure OpenAI model connection name connected to the Foundry project account.
101-
- Replace `"{{deploymentName}}"` with the Azure OpenAI deployment name of the AOAI connection account.
134+
- For Option 1 (Foundry project deployments): Replace `"{{connectionName}}/{{deploymentName}}"` with just `"{{deploymentName}}"` (your model deployment name).
135+
- For Option 2 (Azure OpenAI/AI Services deployments): Replace `"{{connectionName}}"` with the Azure OpenAI model connection name connected to the Foundry project account, and replace `"{{deploymentName}}"` with the Azure OpenAI deployment name of the Azure OpenAI connection account.
102136

103137
---
104138

articles/ai-foundry/how-to/develop/run-scans-ai-red-teaming-agent.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ This article guides you through the process of
2828

2929
- An Azure AI Foundry project or hubs based project. To learn more, see [Create a project](../create-projects.md).
3030

31-
If this is your first time running evaluations or AI red teaming runs on your Azure AI Foundry project, you might need to do a few additional setup steps.
32-
33-
1. [Create and connect your storage account](https://github.com/azure-ai-foundry/foundry-samples/blob/main/samples/microsoft/infrastructure-setup/01-connections/connection-storage-account.bicep) to your Azure AI Foundry project at the resource level. This bicep template provisions and connects a storage account to your Foundry project with key authentication.
34-
2. Make sure the connected storage account has access to all projects.
35-
3. If you connected your storage account with Microsoft Entra ID, make sure to give MSI (Microsoft Identity) permissions for Storage Blob Data Owner to both your account and Foundry project resource in Azure portal.
31+
[!INCLUDE [evaluation-foundry-project-storage](../../includes/evaluation-foundry-project-storage.md)]
3632

3733
## Getting started
3834

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Include file
3+
description: Include file
4+
author: lgayhardt
5+
ms.service: azure-ai-foundry
6+
ms.topic: include
7+
ms.date: 7/23/2025
8+
ms.author: lagayhar
9+
ms.custom: include file
10+
---
11+
12+
If this is your first time running evaluations and logging it to your Azure AI Foundry project, you might need to do a few additional steps:
13+
14+
1. Create and connect your storage account to your Azure AI Foundry project at the resource level. There are two ways you can do this. You can [use a Bicep template](https://github.com/azure-ai-foundry/foundry-samples/blob/main/samples/microsoft/infrastructure-setup/01-connections/connection-storage-account.bicep), which provisions and connects a storage account to your Foundry project with key authentication. You can also [manually create and provision access](../how-to/evaluations-storage-account.md) to your storage account in the Azure portal.
15+
1. Make sure the connected storage account has access to all projects.
16+
1. If you connected your storage account with Microsoft Entra ID, make sure to give managed identity **Storage Blob Data Owner** permissions to both your account and the Foundry project resource in the Azure portal.

0 commit comments

Comments
 (0)