Skip to content

Commit 84d5584

Browse files
authored
Update TSG for red team (#43870)
1 parent 57ce420 commit 84d5584

File tree

1 file changed

+55
-20
lines changed

1 file changed

+55
-20
lines changed

sdk/evaluation/azure-ai-evaluation/TROUBLESHOOTING.md

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ This guide walks you through how to investigate failures, common errors in the `
1414
- [Need to generate simulations for specific harm type](#need-to-generate-simulations-for-specific-harm-type)
1515
- [Simulator is slow](#simulator-is-slow)
1616
- [Handle RedTeam Errors](#handle-redteam-errors)
17+
- [Permission or authentication failures](#permission-or-authentication-failures)
1718
- [Target resource not found](#target-resource-not-found)
19+
- [Agent name not found](#agent-name-not-found)
1820
- [Insufficient Storage Permissions](#insufficient-storage-permissions)
21+
- [PyRIT "Error sending prompt" message](#pyrit-error-sending-prompt-message)
1922
- [Logging](#logging)
2023
- [Get Additional Help](#get-additional-help)
2124

@@ -56,39 +59,71 @@ Adversarial simulators use Azure AI Studio safety evaluation backend service to
5659
5760
The Adversarial simulator does not support selecting individual harms, instead we recommend running the `AdversarialSimulator` for 4x the number of specific harms as the `max_simulation_results`
5861
59-
6062
### Simulator is slow
6163
6264
Identify the type of simulations being run (adversarial or non-adversarial).
6365
Adjust parameters such as `api_call_retry_sleep_sec`, `api_call_delay_sec`, and `concurrent_async_task`. Please note that rate limits to llm calls can be both tokens per minute and requests per minute.
6466
6567
## Handle RedTeam errors
6668
69+
### Permission or authentication failures
70+
- Run `az login` in the active shell before starting the scan and ensure the account has the **Azure AI User** role plus the `Storage Blob Data Contributor` assignment on the linked storage account. Both are required to create evaluation runs and upload artifacts.
71+
- In secured hubs, confirm the linked storage account allows access from your network (or private endpoint) and that Entra ID authentication is enabled on the storage resource.
72+
- If the helper warns `This may be due to missing environment variables or insufficient permissions.`, double-check the `AZURE_PROJECT_ENDPOINT`, `AGENT_NAME`, and storage role assignments before retrying.
73+
6774
### Target resource not found
68-
When initializing an Azure OpenAI model directly as `target` for a `RedTeam` scan, ensure `azure_endpoint` is specified in the format `https://<hub>.openai.azure.com/openai/deployments/<deployment_name>/chat/completions?api-version=2025-01-01-preview`. If using `AzureOpenAI`, `endpoint` should be specified in the format `https://<hub>.openai.azure.com/`.
75+
- When initializing an Azure OpenAI deployment directly as the `target`, specify `azure_endpoint` as `https://<hub>.openai.azure.com/openai/deployments/<deployment_name>/chat/completions?api-version=2025-01-01-preview`.
76+
- If you instantiate `AzureOpenAI`, use the resource-level endpoint format `https://<hub>.openai.azure.com/` and ensure the deployment name plus API version match an active deployment.
77+
- A cloud run error such as `Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}` when creating the eval group can also indicate that `azure-ai-projects>=2.0.0b1` is not installed. Upgrade to that version or later to access the preview APIs used by Red Team.
78+
79+
### Agent name not found
80+
- `(not_found) Agent <name> doesn’t exist` means the Azure AI project could not resolve the agent `name`. Names are case sensitive and differ from display names.
81+
- Verify the `AZURE_PROJECT_ENDPOINT` points to the correct project and that the agent is published there.
82+
- Requires `DefaultAzureCredential` from `azure.identity` and `AIProjectClient` from `azure.ai.projects`.
83+
- Use the following helper to list agents in the current project and confirm the `name` column matches your `AGENT_NAME` value:
84+
85+
```python
86+
def list_project_agents(endpoint: str | None = None) -> None:
87+
project_endpoint = endpoint or os.environ.get("AZURE_PROJECT_ENDPOINT") or ""
88+
if not project_endpoint:
89+
print("Set AZURE_PROJECT_ENDPOINT before listing agents.")
90+
return
91+
with DefaultAzureCredential() as project_credential:
92+
with AIProjectClient(
93+
endpoint=project_endpoint,
94+
credential=project_credential,
95+
api_version="2025-11-15-preview",
96+
) as project_client:
97+
agents = list(project_client.agents.list())
98+
if not agents:
99+
print(f"No agents found in project: {project_endpoint}")
100+
return
101+
print(f"Agents in {project_endpoint}:")
102+
for agent in agents:
103+
display_name = agent.get("display_name") if isinstance(agent, dict) else getattr(agent, "display_name", "")
104+
name = agent.get("name") if isinstance(agent, dict) else getattr(agent, "name", "")
105+
print(f"- name: {name} | display_name: {display_name}")
106+
```
69107
70108
### Insufficient Storage Permissions
71-
If you see an error like `WARNING: Failed to log artifacts to MLFlow: (UserError) Failed to upload evaluation run to the cloud due to insufficient permission to access the storage`, you need to ensure that proper permissions are assigned to the storage account linked to your Azure AI Project.
72-
73-
To fix this issue:
74-
1. Open the associated resource group being used in your Azure AI Project in the Azure Portal
75-
2. Look up the storage accounts associated with that resource group
76-
3. Open each storage account and click on "Access control (IAM)" on the left side navigation
77-
4. Add permissions for the desired users with the "Storage Blob Data Contributor" role
78-
79-
If you have Azure CLI, you can use the following command:
80-
81-
```Shell
82-
# <mySubscriptionID>: Subscription ID of the Azure AI Studio hub's linked storage account (available in Azure AI hub resource view in Azure Portal).
83-
# <myResourceGroupName>: Resource group of the Azure AI Studio hub's linked storage account.
84-
# <user-id>: User object ID for role assignment (retrieve with "az ad user show" command).
85-
86-
az role assignment create --role "Storage Blob Data Contributor" --scope /subscriptions/<mySubscriptionID>/resourceGroups/<myResourceGroupName> --assignee-principal-type User --assignee-object-id "<user-id>"
87-
```
109+
- `WARNING: Failed to log artifacts to MLFlow: (UserError) Failed to upload evaluation run to the cloud due to insufficient permission to access the storage` means the linked storage account is missing the necessary assignments.
110+
- Portal steps:
111+
1. Open the resource group tied to the Azure AI Project in the Azure Portal.
112+
2. Locate the linked storage account(s).
113+
3. Select each storage account and choose **Access control (IAM)**.
114+
4. Grant the affected identity the **Storage Blob Data Contributor** role.
115+
- Prefer CLI? Reuse the `az role assignment create` command described in [Troubleshoot Remote Tracking Issues](#troubleshoot-remote-tracking-issues).
116+
117+
### PyRIT "Error sending prompt" message
118+
- `Exception: Error sending prompt with conversation ID: <guid>` is raised by PyRIT when a target LLM call fails inside the `PromptSendingOrchestrator`. The runner retries the conversation up to the configured limit, so occasional occurrences usually resolve automatically.
119+
- Common triggers include transient network issues, 429 throttling, or 5xx responses from the target deployment. Even if retries succeed you will still see the stack trace in notebook output.
120+
- Inspect the `redteam.log` file written to the scan output directory (typically `<working dir>/runs/<scan_id>/redteam.log`) for the underlying exception and HTTP status. Increase verbosity with `DEBUG=True` for deeper diagnostics.
121+
- Running in Azure AI Studio? Navigate to **Evaluate > Red Team > <run name> > Logs**, download `redteam.log`, and search for the conversation ID to inspect the payload.
122+
- If one conversation ID keeps failing after retries, verify the target credentials, check deployment health, and review Azure OpenAI quota or rate-limit alerts in the Azure portal.
88123
89124
## Logging
90125
91-
You can set logging level via environment variable `PF_LOGGING_LEVEL`, valid values includes `CRITICAL`, `ERROR`, `WARNING`, `INFO`, `DEBUG`, default to `INFO`.
126+
You can set logging level via environment variable `PF_LOGGING_LEVEL`, valid values include `CRITICAL`, `ERROR`, `WARNING`, `INFO`, `DEBUG`; default is `INFO`.
92127
93128
## Get Additional Help
94129

0 commit comments

Comments
 (0)