Skip to content

Commit cb04b75

Browse files
sdgilleyjonburchelgeabdlucaAhmadAbdullah91KazuOnuki
authored
Merge nov25-updates (#403)
* merge main into branch (#338) * Removed code until ready for publication (#332) * Delete samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype directory * Delete samples/microsoft/java/developer-journey-stage-1-idea-to-prototype directory * Delete samples/microsoft/python/developer-journey-stage-1-idea-to-prototype directory * Delete samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype directory * Adding Projects to Vnet Injected Foundry (#324) * Add Bicep file for private network agent project setup creating additional projects for account * Add parameters for second project setup Added parameters for a new project setup including details for existing AI services and shared resources. * Add script to get existing Azure resources This script retrieves the names of existing Azure resources such as AI Services, Storage Account, AI Search Service, and Cosmos DB Account from a specified Resource Group to be used on add-project.bicepparam * Add Bicep file for AI project identity setup This Bicep file defines parameters and resources for setting up a project with unique connection names for CosmosDB, Azure Storage, and Azure Cognitive Search, utilizing system-assigned identity. * Add role assignments for blob storage container adds roles for projects in add-project.bicep * Enhance README with multi-project deployment guide Added a guide for adding multiple projects to AI Foundry deployment, including prerequisites and steps * Update README with VNET address space guidelines (#330) Clarified VNET address space overlap requirements. * clarify network parameter behavior for new vs existing VNet in main.bicepparam (#329) Updated comments to clarify network configuration behavior based on existing VNet resource ID. * Add new CODEOWNERS entries for Terraform files (#335) --------- Co-authored-by: Jon Burchel <jburchel@microsoft.com> Co-authored-by: geabdluca <73857153+geabdluca@users.noreply.github.com> Co-authored-by: AhmadAbdullah91 <91725950+AhmadAbdullah91@users.noreply.github.com> Co-authored-by: kazuyaonuki-MSFT <93357408+KazuOnuki@users.noreply.github.com> Co-authored-by: s-polly <109610942+s-polly@users.noreply.github.com> * Enterprise agent tutorial: Stage 1 - Idea to prototype (#331) * Starting from scratch after issues arose with non-Python samples in testing * Updates to sample content data * Fixes for other languages * Updates * Pre-upgrade commit: saving current state before Java 21 upgrade * Upgrade project to Java 21 using openrewrite. * Clean up extraneous files: remove status reports, .vscode, and build artifacts * Update all enterprise-agent-tutorial READMEs to match Python style with emojis, encouragement, and better structure * Configure Java pom.xml for ultra-minimal structure with source files in project root * Remove .vscode directory from tracking * Add comprehensive validation summary documenting all changes and test results * Remove duplicate .env files from python/enterprise-agent-tutorial parent directory * Fixes * Updates to fix C# * Fixes to C# * Now C# and Python both fully working. Whew... * Structural improvements and fixes to Evaluate project. * Improvements to sample questions, fixes to C# SharePoint implementation * Python updates for SDK 2.0 * C# updates for SDK v2 * Java implementation * Adds tags to samples for doc references * 2025 10 22 enterprise agent tutorial updates (#340) * Starting from scratch after issues arose with non-Python samples in testing * Updates to sample content data * Fixes for other languages * Updates * Pre-upgrade commit: saving current state before Java 21 upgrade * Upgrade project to Java 21 using openrewrite. * Clean up extraneous files: remove status reports, .vscode, and build artifacts * Update all enterprise-agent-tutorial READMEs to match Python style with emojis, encouragement, and better structure * Configure Java pom.xml for ultra-minimal structure with source files in project root * Remove .vscode directory from tracking * Add comprehensive validation summary documenting all changes and test results * Remove duplicate .env files from python/enterprise-agent-tutorial parent directory * Fixes * Updates to fix C# * Fixes to C# * Now C# and Python both fully working. Whew... * Structural improvements and fixes to Evaluate project. * Improvements to sample questions, fixes to C# SharePoint implementation * Python updates for SDK 2.0 * C# updates for SDK v2 * Java implementation * Adds tags to samples for doc references * Improvement to code layout * Add non-runnable code snippet notes in main.py Added notes indicating that the code snippets are non-runnable parts of a larger sample. * Add non-runnable snippet notes to evaluate.py Added notes indicating that the code snippets are non-runnable parts of a larger sample. * Add notes for non-runnable code snippets Added notes indicating that the code snippets are non-runnable parts of a larger sample. * Add notes for non-runnable code snippets Added notes indicating that the code snippets are non-runnable. * Add notes for non-runnable code snippets Added notes indicating that code snippets are non-runnable. * Add non-runnable snippet notes to ModernWorkplaceAssistant Added notes indicating that the code snippets are non-runnable parts of a larger sample. * enterprise-agent-tutorial\2-prototype-to-production (#342) * Developer journey tutorial: Stage 3 - Production to adoption (#343) * Delete samples/microsoft/csharp/enterprise-agent-tutorial/2-prototype-to-production directory * Delete samples/microsoft/csharp/enterprise-agent-tutorial/3-production-to-adoption directory * Delete samples/microsoft/python/enterprise-agent-tutorial/2-prototype-to-production directory * Delete samples/microsoft/python/enterprise-agent-tutorial/3-production-to-adoption directory * Delete samples/microsoft/java/enterprise-agent-tutorial/2-prototype-to-production directory * Delete samples/microsoft/java/enterprise-agent-tutorial/3-production-to-adoption directory * Delete samples/microsoft/enterprise-agent-tutorial directory * create samples-v2 * change model * Adding Quickstart for Python Agents v2 * Revert "Adding Quickstart for Python Agents v2" This reverts commit 3843848. * Added Python Quickstart * Adding REST Quickstart * Tidying up the code pieces * Update quickstart Python files (#355) * initial submit * updated based on feedback * use env var for agent name * Fixed commenting in python files. Added separate samples for REST * add codeowner for the samples-v2 directory in branch * initial submit (#357) * Nov25 updates (#358) * Removed code until ready for publication (#332) * Delete samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype directory * Delete samples/microsoft/java/developer-journey-stage-1-idea-to-prototype directory * Delete samples/microsoft/python/developer-journey-stage-1-idea-to-prototype directory * Delete samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype directory * Adding Projects to Vnet Injected Foundry (#324) * Add Bicep file for private network agent project setup creating additional projects for account * Add parameters for second project setup Added parameters for a new project setup including details for existing AI services and shared resources. * Add script to get existing Azure resources This script retrieves the names of existing Azure resources such as AI Services, Storage Account, AI Search Service, and Cosmos DB Account from a specified Resource Group to be used on add-project.bicepparam * Add Bicep file for AI project identity setup This Bicep file defines parameters and resources for setting up a project with unique connection names for CosmosDB, Azure Storage, and Azure Cognitive Search, utilizing system-assigned identity. * Add role assignments for blob storage container adds roles for projects in add-project.bicep * Enhance README with multi-project deployment guide Added a guide for adding multiple projects to AI Foundry deployment, including prerequisites and steps * Update README with VNET address space guidelines (#330) Clarified VNET address space overlap requirements. * clarify network parameter behavior for new vs existing VNet in main.bicepparam (#329) Updated comments to clarify network configuration behavior based on existing VNet resource ID. * Add new CODEOWNERS entries for Terraform files (#335) * BYO Storage for Speech and Language in Foundry resources (#337) * Included BYOS for Speech and Language BICEP * allowProjectManagement changed to true * updated bicep template to include storage account check * allowing for template to take in storage accounts from another subscriptions, but not create one in another sub. * updated README.md * updated README.md for final check * Add UMI support for private network-secured setup for agents (#341) * added aca env bicep * add umi pvt setup * remove princiaplId output * update azuredeply json and readme * Revert "added aca env bicep" This reverts commit d1b08be. * Update samples/microsoft/infrastructure-setup/17-private-network-standard-user-assigned-identity-agent-setup/README.md Co-authored-by: Meera Kurup <meerakurup@microsoft.com> * update readme for classA support --------- Co-authored-by: Meera Kurup <meerakurup@microsoft.com> * enterprise-agent-tutorial\2-prototype-to-production * Remove whitelisting note in README and main (#344) Remove whitelisting note in README and main * Update README with additional reserved IP range (#346) Update README with additional reserved IP range * SDK v2 updates * Got Java working fully now * Updates TypeScript and C# samples to work with SDKv2 * Policy samples (#349) * deny connection variants * include custom policy samples * update readme for delete acc caphost (#353) * Add policy sample to restrict to aiservices kind (#350) * deny connection variants * include custom policy samples * add sample * fix sample * fix missing var * Updates TypeScript Golden Path tutorial * update readme and scripts (#356) * Syncs questions.jsonl between all 3 samples --------- Co-authored-by: geabdluca <73857153+geabdluca@users.noreply.github.com> Co-authored-by: AhmadAbdullah91 <91725950+AhmadAbdullah91@users.noreply.github.com> Co-authored-by: kazuyaonuki-MSFT <93357408+KazuOnuki@users.noreply.github.com> Co-authored-by: s-polly <109610942+s-polly@users.noreply.github.com> Co-authored-by: Andy <127872853+andyaviles121@users.noreply.github.com> Co-authored-by: sarajag <64988727+sarajag@users.noreply.github.com> Co-authored-by: Meera Kurup <meerakurup@microsoft.com> Co-authored-by: Dennis Eikelenboom <92387505+deeikele@users.noreply.github.com> * Add fallback for SharePoint tool configuration * Nov25 updates (#390) * Removed code until ready for publication (#332) * Delete samples/microsoft/csharp/developer-journey-stage-1-idea-to-prototype directory * Delete samples/microsoft/java/developer-journey-stage-1-idea-to-prototype directory * Delete samples/microsoft/python/developer-journey-stage-1-idea-to-prototype directory * Delete samples/microsoft/typescript/developer-journey-stage-1-idea-to-prototype directory * Adding Projects to Vnet Injected Foundry (#324) * Add Bicep file for private network agent project setup creating additional projects for account * Add parameters for second project setup Added parameters for a new project setup including details for existing AI services and shared resources. * Add script to get existing Azure resources This script retrieves the names of existing Azure resources such as AI Services, Storage Account, AI Search Service, and Cosmos DB Account from a specified Resource Group to be used on add-project.bicepparam * Add Bicep file for AI project identity setup This Bicep file defines parameters and resources for setting up a project with unique connection names for CosmosDB, Azure Storage, and Azure Cognitive Search, utilizing system-assigned identity. * Add role assignments for blob storage container adds roles for projects in add-project.bicep * Enhance README with multi-project deployment guide Added a guide for adding multiple projects to AI Foundry deployment, including prerequisites and steps * Update README with VNET address space guidelines (#330) Clarified VNET address space overlap requirements. * clarify network parameter behavior for new vs existing VNet in main.bicepparam (#329) Updated comments to clarify network configuration behavior based on existing VNet resource ID. * Add new CODEOWNERS entries for Terraform files (#335) * BYO Storage for Speech and Language in Foundry resources (#337) * Included BYOS for Speech and Language BICEP * allowProjectManagement changed to true * updated bicep template to include storage account check * allowing for template to take in storage accounts from another subscriptions, but not create one in another sub. * updated README.md * updated README.md for final check * Add UMI support for private network-secured setup for agents (#341) * added aca env bicep * add umi pvt setup * remove princiaplId output * update azuredeply json and readme * Revert "added aca env bicep" This reverts commit d1b08be. * Update samples/microsoft/infrastructure-setup/17-private-network-standard-user-assigned-identity-agent-setup/README.md Co-authored-by: Meera Kurup <meerakurup@microsoft.com> * update readme for classA support --------- Co-authored-by: Meera Kurup <meerakurup@microsoft.com> * enterprise-agent-tutorial\2-prototype-to-production * Remove whitelisting note in README and main (#344) Remove whitelisting note in README and main * Update README with additional reserved IP range (#346) Update README with additional reserved IP range * SDK v2 updates * Got Java working fully now * Updates TypeScript and C# samples to work with SDKv2 * Policy samples (#349) * deny connection variants * include custom policy samples * update readme for delete acc caphost (#353) * Add policy sample to restrict to aiservices kind (#350) * deny connection variants * include custom policy samples * add sample * fix sample * fix missing var * Updates TypeScript Golden Path tutorial * update readme and scripts (#356) * Syncs questions.jsonl between all 3 samples * Fix * Updates to golden path tutorial --------- Co-authored-by: geabdluca <73857153+geabdluca@users.noreply.github.com> Co-authored-by: AhmadAbdullah91 <91725950+AhmadAbdullah91@users.noreply.github.com> Co-authored-by: kazuyaonuki-MSFT <93357408+KazuOnuki@users.noreply.github.com> Co-authored-by: s-polly <109610942+s-polly@users.noreply.github.com> Co-authored-by: Andy <127872853+andyaviles121@users.noreply.github.com> Co-authored-by: sarajag <64988727+sarajag@users.noreply.github.com> Co-authored-by: Meera Kurup <meerakurup@microsoft.com> Co-authored-by: Dennis Eikelenboom <92387505+deeikele@users.noreply.github.com> * move enterprise-agent-tutorial * move quickstart * remove sln file --------- Co-authored-by: Jon Burchel <jburchel@microsoft.com> Co-authored-by: geabdluca <73857153+geabdluca@users.noreply.github.com> Co-authored-by: AhmadAbdullah91 <91725950+AhmadAbdullah91@users.noreply.github.com> Co-authored-by: kazuyaonuki-MSFT <93357408+KazuOnuki@users.noreply.github.com> Co-authored-by: s-polly <109610942+s-polly@users.noreply.github.com> Co-authored-by: Bala P V <33712765+balapv@users.noreply.github.com> Co-authored-by: John Alexander (MSFT) <174467815+ms-johnalex@users.noreply.github.com> Co-authored-by: Andy <127872853+andyaviles121@users.noreply.github.com> Co-authored-by: sarajag <64988727+sarajag@users.noreply.github.com> Co-authored-by: Meera Kurup <meerakurup@microsoft.com> Co-authored-by: Dennis Eikelenboom <92387505+deeikele@users.noreply.github.com>
1 parent b514983 commit cb04b75

File tree

55 files changed

+4862
-2
lines changed

Some content is hidden

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

55 files changed

+4862
-2
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# See for instructions on this file https://help.github.com/articles/about-codeowners/
2-
2+
#### TEMPORARY CODEOWNER FOR THIS BRANCH
3+
/samples-v2/ @sdgilley
34
#### files referenced in docs (DO NOT EDIT, except for Docs team!!!) #############################################################################
45
/samples/microsoft/REST/mslearn-resources/quickstart/quickstart.sh @azure-ai-foundry/AI-Platform-Docs
56
/samples/microsoft/csharp/mslearn-resources/quickstart/Samples/.env.example @azure-ai-foundry/AI-Platform-Docs

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,5 +456,6 @@ override.tf.json
456456
# Ignore CLI configuration files
457457
.terraformrc
458458
terraform.rc
459-
samples/microsoft/developer-journey-stage-1-idea-to-prototype.md
459+
samples/microsoft/nul
460460
samples/microsoft/microsoft.sln
461+
samples/microsoft/developer-journey-stage-1-idea-to-prototype.md

infrastructure/infrastructure-setup-bicep/41-standard-agent-setup/modules-standard/cosmos-container-role-assignments.bicep

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ resource containerRoleAssignmentUserContainer 'Microsoft.DocumentDB/databaseAcco
3131
}
3232
}
3333

34+
35+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Optional Step: Create a conversation to use with the agent
2+
curl -X POST https://YOUR-FOUNDRY-RESOURCE-NAME.services.ai.azure.com/api/projects/YOUR-PROJECT-NAME/openai/conversations?api-version=2025-11-15-preview \
3+
-H "Content-Type: application/json" \
4+
-H "Authorization: Bearer $AZURE_AI_AUTH_TOKEN" \
5+
-d '{}'
6+
# Lets say Conversation ID created is conv_123456789. Use this in the next step
7+
8+
#Chat with the agent to answer questions
9+
curl -X POST https://YOUR-FOUNDRY-RESOURCE-NAME.services.ai.azure.com/api/projects/YOUR-PROJECT-NAME/openai/responses?api-version=2025-11-15-preview \
10+
-H "Content-Type: application/json" \
11+
-H "Authorization: Bearer $AZURE_AI_AUTH_TOKEN" \
12+
-d '{
13+
"agent": {"type": "agent_reference", "name": "MyAgent"},
14+
"conversation" : "<YOUR_CONVERSATION_ID>",
15+
"input" : "What is the size of France in square miles?"
16+
}'
17+
18+
#Optional Step: Ask a follow-up question in the same conversation
19+
curl -X POST https://YOUR-FOUNDRY-RESOURCE-NAME.services.ai.azure.com/api/projects/YOUR-PROJECT-NAME/openai/responses?api-version=2025-11-15-preview \
20+
-H "Content-Type: application/json" \
21+
-H "Authorization: Bearer $AZURE_AI_AUTH_TOKEN" \
22+
-d '{
23+
"agent": {"type": "agent_reference", "name": "MyAgent"},
24+
"conversation" : "<YOUR_CONVERSATION_ID>",
25+
"input" : "And what is the capital city?"
26+
}'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
curl -X POST https://YOUR-FOUNDRY-RESOURCE-NAME.services.ai.azure.com/api/projects/YOUR-PROJECT-NAME/agents?api-version=2025-11-15-preview \
2+
-H "Content-Type: application/json" \
3+
-H "Authorization: Bearer $AZURE_AI_AUTH_TOKEN" \
4+
-d '{
5+
"name": "MyAgent",
6+
"definition": {
7+
"kind": "prompt",
8+
"model": "gpt-4.1-mini",
9+
"instructions": "You are a helpful assistant that answers general questions"
10+
}
11+
}'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
curl -X POST https://YOUR-FOUNDRY-RESOURCE-NAME.services.ai.azure.com/api/projects/YOUR-PROJECT-NAME/openai/responses?api-version=2025-11-15-preview \
2+
-H "Content-Type: application/json" \
3+
-H "Authorization: Bearer $AZURE_AI_AUTH_TOKEN" \
4+
-d '{
5+
"model": "gpt-4.1-mini",
6+
"input": "What is the size of France in square miles?"
7+
}'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Azure.AI.Agents" Version="2.0.0-alpha.20251016.2" />
12+
<PackageReference Include="Azure.Identity" Version="1.17.0" />
13+
<PackageReference Include="DotNetEnv" Version="3.1.1" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="OpenAI" Version="2.*-*" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
// <imports_and_includes>
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Text.Json;
7+
using System.Threading.Tasks;
8+
using Azure;
9+
using Azure.AI.Agents;
10+
using Azure.Core;
11+
using Azure.Identity;
12+
using DotNetEnv;
13+
using OpenAI;
14+
using OpenAI.Responses;
15+
// </imports_and_includes>
16+
17+
class EvaluateProgram
18+
{
19+
static async Task Main(string[] args)
20+
{
21+
// Load environment variables from shared directory
22+
Env.Load("../shared/.env");
23+
24+
var projectEndpoint = Environment.GetEnvironmentVariable("PROJECT_ENDPOINT");
25+
var modelDeploymentName = Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME");
26+
var sharepointConnectionId = Environment.GetEnvironmentVariable("SHAREPOINT_CONNECTION_ID");
27+
var mcpServerUrl = Environment.GetEnvironmentVariable("MCP_SERVER_URL");
28+
var tenantId = Environment.GetEnvironmentVariable("AI_FOUNDRY_TENANT_ID");
29+
30+
// Use tenant-specific credential if provided
31+
TokenCredential credential;
32+
if (!string.IsNullOrEmpty(tenantId))
33+
{
34+
credential = new AzureCliCredential(new AzureCliCredentialOptions { TenantId = tenantId });
35+
}
36+
else
37+
{
38+
credential = new DefaultAzureCredential();
39+
}
40+
41+
AgentsClient client = new(new Uri(projectEndpoint), credential);
42+
43+
Console.WriteLine("🧪 Modern Workplace Assistant Evaluation\n");
44+
45+
List<ToolDefinition> tools = new();
46+
47+
// Add SharePoint tool if configured
48+
if (!string.IsNullOrEmpty(sharepointConnectionId))
49+
{
50+
try
51+
{
52+
SharepointToolDefinition sharepointTool = new(new SharepointGroundingToolParameters(sharepointConnectionId));
53+
tools.Add(sharepointTool);
54+
Console.WriteLine("✅ SharePoint configured for evaluation");
55+
}
56+
catch (Exception ex)
57+
{
58+
Console.WriteLine($"⚠️ SharePoint unavailable: {ex.Message}");
59+
}
60+
}
61+
62+
// Add MCP tool if configured
63+
if (!string.IsNullOrEmpty(mcpServerUrl))
64+
{
65+
try
66+
{
67+
MCPToolDefinition mcpTool = new("microsoft_learn", mcpServerUrl);
68+
tools.Add(mcpTool);
69+
Console.WriteLine("✅ MCP configured for evaluation");
70+
}
71+
catch (Exception ex)
72+
{
73+
Console.WriteLine($"⚠️ MCP unavailable: {ex.Message}");
74+
}
75+
}
76+
77+
Console.WriteLine();
78+
79+
var instructions = @"You are a Modern Workplace Assistant for Contoso Corporation.
80+
Answer questions using available tools and provide specific, detailed responses.";
81+
82+
AgentDefinition agentDefinition = new PromptAgentDefinition(modelDeploymentName)
83+
{
84+
Instructions = instructions,
85+
Tools = tools
86+
};
87+
88+
AgentVersion agent = await client.CreateAgentVersionAsync(
89+
"Evaluation Agent",
90+
agentDefinition
91+
);
92+
93+
// <load_test_data>
94+
var questions = File.ReadAllLines("../shared/questions.jsonl")
95+
.Select(line => JsonSerializer.Deserialize<JsonElement>(line))
96+
.ToList();
97+
// </load_test_data>
98+
99+
// <run_batch_evaluation>
100+
// NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken.
101+
var results = new List<object>();
102+
103+
Console.WriteLine($"Running {questions.Count} evaluation questions...\n");
104+
105+
for (int i = 0; i < questions.Count; i++)
106+
{
107+
var q = questions[i];
108+
var question = q.GetProperty("question").GetString()!;
109+
110+
string[] expectedKeywords = Array.Empty<string>();
111+
if (q.TryGetProperty("expected_keywords", out var keywordsElem))
112+
{
113+
expectedKeywords = keywordsElem.EnumerateArray()
114+
.Select(e => e.GetString()!)
115+
.ToArray();
116+
}
117+
118+
Console.WriteLine($"Question {i + 1}/{questions.Count}: {question}");
119+
120+
// Get OpenAI client from the agents client
121+
OpenAIClient openAIClient = client.GetOpenAIClient();
122+
OpenAIResponseClient responseClient = openAIClient.GetOpenAIResponseClient(modelDeploymentName);
123+
124+
// Create a conversation to maintain state
125+
AgentConversation conversation = await client.GetConversationsClient().CreateConversationAsync();
126+
127+
// Set up response creation options with agent and conversation references
128+
ResponseCreationOptions responseCreationOptions = new();
129+
responseCreationOptions.SetAgentReference(agent.Name);
130+
responseCreationOptions.SetConversationReference(conversation);
131+
132+
// Create the user message item
133+
List<ResponseItem> items = [ResponseItem.CreateUserMessageItem(question)];
134+
135+
string response = "";
136+
try
137+
{
138+
// Create response from the agent
139+
OpenAIResponse openAIResponse = await responseClient.CreateResponseAsync(items, responseCreationOptions);
140+
response = openAIResponse.GetOutputText();
141+
}
142+
catch (Exception ex)
143+
{
144+
Console.WriteLine($" ⚠️ Error: {ex.Message}");
145+
response = "";
146+
}
147+
148+
bool passed = response.Length > 50;
149+
if (expectedKeywords.Length > 0)
150+
{
151+
passed = passed && expectedKeywords.Any(k => response.Contains(k, StringComparison.OrdinalIgnoreCase));
152+
}
153+
154+
Console.WriteLine($" Status: {(passed ? "✅ PASS" : "❌ FAIL")}");
155+
Console.WriteLine($" Response length: {response.Length} characters\n");
156+
157+
results.Add(new
158+
{
159+
question,
160+
response,
161+
passed,
162+
response_length = response.Length
163+
});
164+
}
165+
// </run_batch_evaluation>
166+
167+
// Cleanup - Note: In SDK 2.0, agents are versioned and managed differently
168+
// await client.DeleteAgentAsync(agent.Name); // Uncomment if you want to delete
169+
170+
// <evaluation_results>
171+
// NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken.
172+
var summary = new
173+
{
174+
total_questions = questions.Count,
175+
passed = results.Count(r => ((dynamic)r).passed),
176+
failed = results.Count(r => !((dynamic)r).passed),
177+
results
178+
};
179+
180+
var json = JsonSerializer.Serialize(summary, new JsonSerializerOptions { WriteIndented = true });
181+
File.WriteAllText("evaluation_results.json", json);
182+
183+
Console.WriteLine($"📊 Evaluation Complete:");
184+
Console.WriteLine($" Total: {summary.total_questions}");
185+
Console.WriteLine($" Passed: {summary.passed}");
186+
Console.WriteLine($" Failed: {summary.failed}");
187+
Console.WriteLine($"\n📄 Results saved to evaluation_results.json");
188+
// </evaluation_results>
189+
}
190+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"total_questions": 4,
3+
"passed": 4,
4+
"failed": 0,
5+
"results": [
6+
{
7+
"question": "What is our remote work policy regarding security requirements?",
8+
"response": "Our remote work policy regarding security requirements includes the following key points:\n\n- A secure VPN connection is required for remote access.\n- Use of Microsoft 365 and Azure services is mandatory.\n- Multi-factor authentication (MFA) must be enabled.\n- Personal devices used for remote work must meet security standards.\n- All data must be stored in approved cloud services such as SharePoint and OneDrive.\n- No sensitive data is allowed to be stored on personal devices.\n- Employees are required to complete regular security training.\n- Security incidents must be reported within 2 hours.\n\nThese measures ensure secure and compliant remote work practices at Contoso Corporation\u30103:1\u2020source\u3011.",
9+
"passed": true,
10+
"response_length": 697
11+
},
12+
{
13+
"question": "How do I set up Azure Active Directory conditional access?",
14+
"response": "To set up Azure Active Directory (Azure AD) Conditional Access, follow these summarized steps:\n\n1. Sign in to the Azure portal (https://portal.azure.com).\n\n2. Open your Azure Active Directory tenant.\n\n3. Go to the \u0022Security\u0022 section and select \u0022Conditional Access.\u0022\n\n4. Click on \u0022New policy\u0022 to create a new Conditional Access policy.\n\n5. Configure the policy:\n - Under \u0022Assignments,\u0022 select \u0022Users and groups\u0022 to define who the policy applies to.\n - Choose \u0022Cloud apps or actions\u0022 to specify which apps or actions the policy targets.\n - Set conditions such as device platform, location, sign-in risk, user risk, etc., as needed.\n \n6. Under \u0022Access controls,\u0022 define controls such as requiring multi-factor authentication (MFA), blocking access, or requiring password change.\n\n7. Enable the policy by setting \u0022Enable policy\u0022 to On.\n\n8. Click \u0022Create\u0022 to save and activate the policy.\n\nImportant notes:\n- Azure AD Conditional Access is available in the Premium tier of Azure AD.\n- To avoid lockout, exclude emergency access or break-glass accounts from the policy.\n- You can use the \u0022What If\u0022 tool in Azure portal to troubleshoot Conditional Access policies.\n\nFor a detailed guide, including best practices and advanced options, see the Microsoft documentation on Configuring Azure Active Directory Conditional Access here: https://learn.microsoft.com/en-us/appcenter/general/configuring-aad-conditional-access\n\nIf you are using Azure AD B2C, the Conditional Access policies can also be applied via the Azure AD B2C section under Security \u003E Conditional Access with options tailored for different risk-based policies.\n\nLet me know if you want step-by-step instructions for a specific scenario or for Azure AD B2C Conditional Access.",
15+
"passed": true,
16+
"response_length": 1738
17+
},
18+
{
19+
"question": "What collaboration tools are approved for internal use?",
20+
"response": "The approved collaboration tools for internal use at Contoso Corporation are:\n\n- Microsoft Teams for meetings and internal communication\n- SharePoint for document collaboration and management\n- Azure DevOps for development projects and source code management\n- Outlook for email and calendar management\n\nThese tools are part of the company\u0027s remote work policy and collaboration standards to ensure secure and effective teamwork within the organization.\u30104:1\u2020source\u3011\u30104:2\u2020source\u3011",
21+
"passed": true,
22+
"response_length": 477
23+
},
24+
{
25+
"question": "What Azure AD configuration should I implement to comply with our company\u0027s remote work security policy?",
26+
"response": "To recommend the appropriate Azure AD configuration for your company\u0027s remote work security policy, I need more details about the specific security requirements in that policy. Common security measures for remote work typically include:\n\n- Multi-Factor Authentication (MFA) enforcement\n- Conditional Access policies based on user location or device compliance\n- Identity Protection to detect and respond to risky sign-ins\n- Device registration and management integration (e.g., Intune)\n- Restricting access to sensitive resources unless certain conditions (secure device, compliant user, approved location) are met\n- Enabling Single Sign-On (SSO) for secure cloud application access\n\nCould you please provide the key security controls or goals from your remote work policy? Or, if you want, I can provide a general recommended Azure AD security setup for remote work environments.",
27+
"passed": true,
28+
"response_length": 880
29+
}
30+
]
31+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
6+
<add key="local-preview" value="F:\git\agentsv2-preview\dotnet\package" />
7+
</packageSources>
8+
</configuration>

0 commit comments

Comments
 (0)