feat(azure-ai-projects): add endpoint evaluator samples for API Key auth and entra id auth#47669
Conversation
…nd Entra ID auth Add two E2E samples demonstrating endpoint-based evaluators: - sample_endpoint_evaluator_with_api_key.py: API Key authentication flow - sample_endpoint_evaluator_with_entra_id.py: Entra ID (managed identity) authentication flow Both samples show the full workflow: create connection, register evaluator, create evaluation, run with inline data, and poll for results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thank you for your contribution @ahmad-nader! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
This PR adds two end-to-end sample scripts to azure-ai-projects demonstrating endpoint-based evaluators — one using API Key authentication and one using Entra ID (managed identity). Each sample walks through creating a workspace connection, registering an evaluator, creating an evaluation, running it with inline data, and polling for results. The samples are intended to live alongside the existing evaluation samples under samples/evaluations/.
The main blocking concern is that both samples depend on a model (EndpointBasedEvaluatorDefinition) that does not exist in the package on the PR's base branch (main), so neither sample can import or run as-is. There is also a Black-formatting issue in the API Key sample, and the new samples are not added to the evaluations README.md index (which the repo convention maintains, though that file is outside this PR's diff).
Changes:
- Adds
sample_endpoint_evaluator_with_entra_id.py(managed-identity auth flow via aCustomKeys/AADconnection). - Adds
sample_endpoint_evaluator_with_api_key.py(API key auth flow via anApiKeyconnection, with anEvaluatorMetricdefinition). - Both rely on
EndpointBasedEvaluatorDefinition, which is not present in the SDK.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| sdk/ai/azure-ai-projects/samples/evaluations/sample_endpoint_evaluator_with_entra_id.py | New Entra ID auth endpoint-evaluator sample; imports nonexistent EndpointBasedEvaluatorDefinition. |
| sdk/ai/azure-ai-projects/samples/evaluations/sample_endpoint_evaluator_with_api_key.py | New API Key auth endpoint-evaluator sample; imports nonexistent EndpointBasedEvaluatorDefinition and has a mis-indented metrics block that fails Black. |
|
Summary: Adds two well-structured, end-to-end evaluation samples to sdk/ai/azure-ai-projects/samples/evaluations/ . The API surface usage is correct — I verified EndpointBasedEvaluatorDefinition , EvaluatorVersion , EvaluatorMetric , EvaluatorCategory , EvaluatorType , and the project_client.beta.evaluators.create_version(name=..., evaluator_version=...) call all match the actual models/operations. Both files compile, follow the existing sample conventions ( get_openai_client() , DataSourceConfigCustom , CreateEvalJSONLRunDataSourceParam , polling loop), and contain no hardcoded secrets (all creds come from env vars). 🔴 Blocking — sample_endpoint_evaluator_with_api_key.py fails the black check The metrics= block (lines ~154–160) has misaligned indentation (one extra leading space, and the inner dict is under-indented). The repo's black CI check (line-length 120) will fail. black reformats it to: Fix: 🟡 Minor nits (non-blocking)
✅ Good • Thorough docstrings covering request/response contract, prereqs, and env vars. Recommendation: Approve after the black reformat on the API-key sample (required for CI). The env-var naming is worth aligning but optional. |
- Add commented-out cleanup for connection, evaluator, and evaluation - Add endpoint evaluator samples to README.md sample index - Rename AZURE_AI_PROJECT_ENDPOINT to FOUNDRY_PROJECT_ENDPOINT - Add EvaluatorMetric and metrics block to Entra ID sample - Fix PascalCase status in Entra ID docstring - Add valid status values comment in both samples Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Please exclude these samples from the test for now, in order to get the build green (see tests\samples). |
|
Please don't forget to run the formatter tool
|
Samples require external scoring endpoint and azure-mgmt-cognitiveservices. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- ApiKeyAuthConnectionProperties + ConnectionApiKey for API key sample - AADAuthTypeConnectionProperties for Entra ID sample Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add two E2E samples demonstrating endpoint-based evaluators:
Both samples show the full workflow: create connection, register evaluator, create evaluation, run with inline data, and poll for results.
Description
Please add an informative description that covers that changes made by the pull request and link all relevant issues.
If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines