From 4b5870d1b4604ed8d3b5d1fe9daa2284d4c7badf Mon Sep 17 00:00:00 2001
From: nick863 <30440255+nick863@users.noreply.github.com>
Date: Wed, 28 Jan 2026 21:04:55 -0800
Subject: [PATCH 1/2] Upgrade agents to v2
---
.../Evaluate/Evaluate.csproj | 5 +-
.../1-idea-to-prototype/Evaluate/Program.cs | 84 +++++++++---------
.../1-idea-to-prototype/Evaluate/nuget.config | 4 +-
.../ModernWorkplaceAssistant.csproj | 5 +-
.../ModernWorkplaceAssistant/Program.cs | 87 +++++++++----------
.../ModernWorkplaceAssistant/nuget.config | 4 +-
.../shared/questions.jsonl | 2 +
samples/csharp/quickstart/AgentService.cs | 39 ++++-----
.../quickstart/quickstart-create-agent.cs | 9 +-
.../csharp/quickstart/quickstart-responses.cs | 13 ++-
10 files changed, 121 insertions(+), 131 deletions(-)
create mode 100644 samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/shared/questions.jsonl
diff --git a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/Evaluate.csproj b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/Evaluate.csproj
index dd0764884..50e4731ba 100644
--- a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/Evaluate.csproj
+++ b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/Evaluate.csproj
@@ -8,8 +8,9 @@
-
-
+
+
+
diff --git a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/Program.cs b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/Program.cs
index b739a52f3..053c53497 100644
--- a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/Program.cs
+++ b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/Program.cs
@@ -1,25 +1,31 @@
๏ปฟ//
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text.Json;
-using System.Threading.Tasks;
using Azure;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Core;
using Azure.Identity;
using DotNetEnv;
-using OpenAI;
using OpenAI.Responses;
+using System;
+using System.Collections.Generic;
+using System.IO.Enumeration;
+using System.Runtime.CompilerServices;
+using System.Text.Json;
+using System.Threading.Tasks;
//
-
+#pragma warning disable OPENAI001
class EvaluateProgram
{
+ private static string GetFile(string name, [CallerFilePath] string pth = "")
+ {
+ var dirName = Path.GetDirectoryName(pth) ?? "";
+ return Path.Combine(dirName, "..", "shared", name);
+ }
+
static async Task Main(string[] args)
{
// Load environment variables from shared directory
- Env.Load("../shared/.env");
+ Env.Load(GetFile(".env"));
var projectEndpoint = Environment.GetEnvironmentVariable("PROJECT_ENDPOINT");
var modelDeploymentName = Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME");
@@ -38,19 +44,28 @@ static async Task Main(string[] args)
credential = new DefaultAzureCredential();
}
- AgentsClient client = new(new Uri(projectEndpoint), credential);
+ AIProjectClient client = new(new Uri(projectEndpoint), credential);
Console.WriteLine("๐งช Modern Workplace Assistant Evaluation\n");
- List tools = new();
+ var instructions = @"You are a Modern Workplace Assistant for Contoso Corporation.
+Answer questions using available tools and provide specific, detailed responses.";
+ PromptAgentDefinition agentDefinition = new PromptAgentDefinition(modelDeploymentName)
+ {
+ Instructions = instructions
+ };
// Add SharePoint tool if configured
if (!string.IsNullOrEmpty(sharepointConnectionId))
{
try
{
- SharepointToolDefinition sharepointTool = new(new SharepointGroundingToolParameters(sharepointConnectionId));
- tools.Add(sharepointTool);
+ SharePointGroundingToolOptions sharepointToolOption = new()
+ {
+ ProjectConnections = { new ToolProjectConnection(projectConnectionId: sharepointConnectionId) }
+ };
+ SharepointPreviewTool sharepointTool = new(sharepointToolOption);
+ agentDefinition.Tools.Add(sharepointTool);
Console.WriteLine("โ
SharePoint configured for evaluation");
}
catch (Exception ex)
@@ -64,8 +79,12 @@ static async Task Main(string[] args)
{
try
{
- MCPToolDefinition mcpTool = new("microsoft_learn", mcpServerUrl);
- tools.Add(mcpTool);
+ McpTool mcpTool = ResponseTool.CreateMcpTool(
+ serverLabel: "microsoft_learn",
+ serverUri: new Uri(mcpServerUrl),
+ toolCallApprovalPolicy: new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.NeverRequireApproval)
+ );
+ agentDefinition.Tools.Add(mcpTool);
Console.WriteLine("โ
MCP configured for evaluation");
}
catch (Exception ex)
@@ -76,22 +95,13 @@ static async Task Main(string[] args)
Console.WriteLine();
- var instructions = @"You are a Modern Workplace Assistant for Contoso Corporation.
-Answer questions using available tools and provide specific, detailed responses.";
-
- AgentDefinition agentDefinition = new PromptAgentDefinition(modelDeploymentName)
- {
- Instructions = instructions,
- Tools = tools
- };
-
- AgentVersion agent = await client.CreateAgentVersionAsync(
- "Evaluation Agent",
- agentDefinition
+ AgentVersion agent = await client.Agents.CreateAgentVersionAsync(
+ agentName: "EvaluationAgent",
+ options: new(agentDefinition)
);
//
- var questions = File.ReadAllLines("../shared/questions.jsonl")
+ var questions = File.ReadAllLines(GetFile("questions.jsonl"))
.Select(line => JsonSerializer.Deserialize(line))
.ToList();
//
@@ -114,20 +124,14 @@ static async Task Main(string[] args)
.Select(e => e.GetString()!)
.ToArray();
}
-
- Console.WriteLine($"Question {i + 1}/{questions.Count}: {question}");
- // Get OpenAI client from the agents client
- OpenAIClient openAIClient = client.GetOpenAIClient();
- OpenAIResponseClient responseClient = openAIClient.GetOpenAIResponseClient(modelDeploymentName);
+ Console.WriteLine($"Question {i + 1}/{questions.Count}: {question}");
// Create a conversation to maintain state
- AgentConversation conversation = await client.GetConversationsClient().CreateConversationAsync();
+ ProjectConversation conversation = await client.OpenAI.Conversations.CreateProjectConversationAsync();
- // Set up response creation options with agent and conversation references
- ResponseCreationOptions responseCreationOptions = new();
- responseCreationOptions.SetAgentReference(agent.Name);
- responseCreationOptions.SetConversationReference(conversation);
+ // Get OpenAI client from the agents client
+ ProjectResponsesClient responseClient = client.OpenAI.GetProjectResponsesClientForAgent(agent, conversation.Id);
// Create the user message item
List items = [ResponseItem.CreateUserMessageItem(question)];
@@ -136,7 +140,7 @@ static async Task Main(string[] args)
try
{
// Create response from the agent
- OpenAIResponse openAIResponse = await responseClient.CreateResponseAsync(items, responseCreationOptions);
+ ResponseResult openAIResponse = await responseClient.CreateResponseAsync(items);
response = openAIResponse.GetOutputText();
}
catch (Exception ex)
diff --git a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/nuget.config b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/nuget.config
index 7f3fb6f6f..b2b33046f 100644
--- a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/nuget.config
+++ b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/nuget.config
@@ -1,8 +1,6 @@
-
-
-
+
diff --git a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/ModernWorkplaceAssistant.csproj b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/ModernWorkplaceAssistant.csproj
index 6077edd6e..84fad1aa7 100644
--- a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/ModernWorkplaceAssistant.csproj
+++ b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/ModernWorkplaceAssistant.csproj
@@ -8,8 +8,9 @@
-
-
+
+
+
diff --git a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/Program.cs b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/Program.cs
index 1a02b74fe..1768a0164 100644
--- a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/Program.cs
+++ b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/Program.cs
@@ -4,29 +4,28 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using Azure;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Core;
using Azure.Identity;
using DotNetEnv;
-using OpenAI;
using OpenAI.Responses;
//
/*
* Azure AI Foundry Agent Sample - Tutorial 1: Modern Workplace Assistant
- *
+ *
* This sample demonstrates a complete business scenario using Azure AI Agents SDK v2:
* - Agent creation with the new SDK
* - Conversation and response management
* - Robust error handling and graceful degradation
- *
+ *
* Educational Focus:
* - Enterprise AI patterns with Agent SDK v2
* - Real-world business scenarios that enterprises face daily
* - Production-ready error handling and diagnostics
* - Foundation for governance, evaluation, and monitoring (Tutorials 2-3)
- *
+ *
* Business Scenario:
* An employee needs to implement Azure AD multi-factor authentication. They need:
* 1. Company security policy requirements
@@ -36,9 +35,9 @@
class Program
{
- private static AgentsClient? agentsClient;
- private static OpenAIResponseClient? responseClient;
- private static AgentConversation? conversation;
+ private static AIProjectClient? projectClient;
+ private static ProjectResponsesClient? responseClient;
+ private static ProjectConversation? conversation;
static async Task Main(string[] args)
{
@@ -57,7 +56,7 @@ static async Task Main(string[] args)
// Offer interactive testing
Console.Write("\n๐ฏ Try interactive mode? (y/n): ");
var response = Console.ReadLine();
- if (response?.ToLower().StartsWith("y") == true)
+ if (response?.StartsWith("y", StringComparison.CurrentCultureIgnoreCase) == true)
{
await InteractiveModeAsync(agentName);
}
@@ -79,17 +78,17 @@ static async Task Main(string[] args)
///
/// Create a Modern Workplace Assistant using Agent SDK v2.
- ///
+ ///
/// This demonstrates enterprise AI patterns:
/// 1. Agent creation with the new SDK
/// 2. Robust error handling with graceful degradation
/// 3. Clear diagnostic information for troubleshooting
- ///
+ ///
/// Educational Value:
/// - Shows real-world complexity of enterprise AI systems
/// - Demonstrates how to handle partial system failures
/// - Provides patterns for agent creation with Agent SDK v2
- ///
+ ///
/// Note: Tool integration (SharePoint, MCP) is being explored for SDK v2 beta.
/// This version demonstrates the core agent functionality.
///
@@ -124,7 +123,7 @@ private static async Task CreateWorkplaceAssistantAsync()
credential = new DefaultAzureCredential();
}
- agentsClient = new AgentsClient(new Uri(projectEndpoint), credential);
+ projectClient = new AIProjectClient(new Uri(projectEndpoint), credential);
Console.WriteLine($"โ
Connected to Azure AI Foundry: {projectEndpoint}");
//
@@ -133,22 +132,22 @@ private static async Task CreateWorkplaceAssistantAsync()
// ========================================================================
string instructions = @"You are a Technical Assistant specializing in Azure and Microsoft 365 guidance.
-CAPABILITIES:
-- Provide detailed Azure and Microsoft 365 technical guidance
-- Explain implementation steps and best practices
-- Help with Azure AD, Conditional Access, MFA, and security configurations
+ CAPABILITIES:
+ - Provide detailed Azure and Microsoft 365 technical guidance
+ - Explain implementation steps and best practices
+ - Help with Azure AD, Conditional Access, MFA, and security configurations
-RESPONSE STRATEGY:
-- Provide comprehensive technical guidance
-- Include step-by-step implementation instructions
-- Reference best practices and security considerations
-- For policy questions, explain common enterprise policies and how to implement them
-- For technical questions, provide detailed Azure/M365 implementation steps
+ RESPONSE STRATEGY:
+ - Provide comprehensive technical guidance
+ - Include step-by-step implementation instructions
+ - Reference best practices and security considerations
+ - For policy questions, explain common enterprise policies and how to implement them
+ - For technical questions, provide detailed Azure/M365 implementation steps
-EXAMPLE SCENARIOS:
-- ""What is a typical enterprise MFA policy?"" โ Explain common MFA policies and their implementation
-- ""How do I configure Azure AD Conditional Access?"" โ Provide detailed technical steps
-- ""What are the best practices for remote work security?"" โ Combine policy recommendations with implementation guidance";
+ EXAMPLE SCENARIOS:
+ - ""What is a typical enterprise MFA policy?"" โ Explain common MFA policies and their implementation
+ - ""How do I configure Azure AD Conditional Access?"" โ Provide detailed technical steps
+ - ""What are the best practices for remote work security?"" โ Combine policy recommendations with implementation guidance";
//
Console.WriteLine($"๐ ๏ธ Creating agent with model: {modelDeploymentName}");
@@ -158,9 +157,9 @@ private static async Task CreateWorkplaceAssistantAsync()
Instructions = instructions
};
- AgentVersion agent = await agentsClient.CreateAgentVersionAsync(
- "Modern_Workplace_Assistant",
- agentDefinition
+ AgentVersion agent = await projectClient.Agents.CreateAgentVersionAsync(
+ agentName: "ModernWorkplaceAssistant",
+ options: new(agentDefinition)
);
Console.WriteLine("โ
Agent created successfully");
@@ -172,22 +171,21 @@ private static async Task CreateWorkplaceAssistantAsync()
Console.WriteLine(" - Tool integration patterns being finalized");
//
- // Initialize OpenAI client for conversations
- OpenAIClient openAIClient = agentsClient.GetOpenAIClient();
- responseClient = openAIClient.GetOpenAIResponseClient(modelDeploymentName);
-
// Create a conversation to maintain state
- conversation = await agentsClient.GetConversationsClient().CreateConversationAsync();
+ conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync();
+
+ // Initialize ProjectResponsesClient for conversations
+ responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agent, conversation.Id);
return agent.Name;
}
///
/// Demonstrate realistic business scenarios with Agent SDK v2.
- ///
+ ///
/// This function showcases the practical value of the Modern Workplace Assistant
/// by walking through scenarios that enterprise employees face regularly.
- ///
+ ///
/// Educational Value:
/// - Shows real business problems that AI agents can solve
/// - Demonstrates proper conversation and response management
@@ -274,9 +272,9 @@ private static async Task DemonstrateBusinessScenariosAsync(string agentName)
///
/// Execute a conversation with the workplace assistant using Agent SDK v2.
- ///
+ ///
/// This function demonstrates the conversation pattern for Azure AI Agents SDK v2.
- ///
+ ///
/// Educational Value:
/// - Shows proper conversation management with Agent SDK v2
/// - Demonstrates conversation creation and message handling
@@ -287,16 +285,11 @@ private static async Task DemonstrateBusinessScenariosAsync(string agentName)
try
{
//
- // Set up response creation options with agent and conversation references
- ResponseCreationOptions responseCreationOptions = new();
- responseCreationOptions.SetAgentReference(agentName);
- responseCreationOptions.SetConversationReference(conversation!);
-
// Create the user message item
List items = [ResponseItem.CreateUserMessageItem(message)];
// Create response from the agent
- OpenAIResponse response = await responseClient!.CreateResponseAsync(items, responseCreationOptions);
+ ResponseResult response = await responseClient!.CreateResponseAsync(items);
// Extract the response text
string responseText = response.GetOutputText();
@@ -317,7 +310,7 @@ private static async Task DemonstrateBusinessScenariosAsync(string agentName)
///
/// Interactive mode for testing the workplace assistant.
- ///
+ ///
/// This provides a simple interface for users to test the agent with their own questions
/// and see how it provides comprehensive technical guidance.
///
diff --git a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/nuget.config b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/nuget.config
index 7f3fb6f6f..b2b33046f 100644
--- a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/nuget.config
+++ b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/nuget.config
@@ -1,8 +1,6 @@
-
-
-
+
diff --git a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/shared/questions.jsonl b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/shared/questions.jsonl
new file mode 100644
index 000000000..dc4a62499
--- /dev/null
+++ b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/shared/questions.jsonl
@@ -0,0 +1,2 @@
+{"question": "Please explain, what is MCP Server."}
+{"question": "Define the Maxwell's equation."}
diff --git a/samples/csharp/quickstart/AgentService.cs b/samples/csharp/quickstart/AgentService.cs
index 4bca72bd1..f3ba7dd0d 100644
--- a/samples/csharp/quickstart/AgentService.cs
+++ b/samples/csharp/quickstart/AgentService.cs
@@ -1,23 +1,21 @@
// This sample combines each step of creating and running agents and conversations into a single example.
// In practice, you would typically separate these steps into different applications.
//
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
-using OpenAI;
using OpenAI.Responses;
#pragma warning disable OPENAI001
-string RAW_PROJECT_ENDPOINT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_PROJECT_ENDPOINT")
- ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_PROJECT_ENDPOINT'");
-string MODEL_DEPLOYMENT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT_NAME")
- ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT_NAME'");
-string AGENT_NAME = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_AGENT_NAME")
- ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_AGENT_NAME'");
+string RAW_PROJECT_ENDPOINT = Environment.GetEnvironmentVariable("PROJECT_ENDPOINT")
+?? throw new InvalidOperationException("Missing environment variable 'PROJECT_ENDPOINT'");
+string MODEL_DEPLOYMENT = Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME")
+?? throw new InvalidOperationException("Missing environment variable 'MODEL_DEPLOYMENT_NAME'");
+string AGENT_NAME = Environment.GetEnvironmentVariable("AGENT_NAME")
+?? throw new InvalidOperationException("Missing environment variable 'AGENT_NAME'");
-AgentClient agentsClient = new(new Uri(RAW_PROJECT_ENDPOINT), new AzureCliCredential());
-OpenAIClient openAIClient = agentsClient.GetOpenAIClient();
-OpenAIResponseClient responseClient = openAIClient.GetOpenAIResponseClient(MODEL_DEPLOYMENT);
+AIProjectClient projectClient = new AIProjectClient(new Uri(RAW_PROJECT_ENDPOINT), new DefaultAzureCredential());
//
// Create an agent version for a new prompt agent
@@ -27,25 +25,25 @@
{
Instructions = "You are a foo bar agent. In EVERY response you give, ALWAYS include both `foo` and `bar` strings somewhere in the response.",
};
-AgentVersion newAgentVersion = await agentsClient.CreateAgentVersionAsync(AGENT_NAME, options: new(agentDefinition));
+AgentVersion newAgentVersion = await projectClient.Agents.CreateAgentVersionAsync(AGENT_NAME, options: new(agentDefinition));
//
// Create a conversation to maintain state between calls
//
-AgentConversationCreationOptions conversationOptions = new()
+ProjectConversationCreationOptions conversationOptions = new()
{
Items = { ResponseItem.CreateSystemMessageItem("Your preferred genre of story today is: horror.") },
Metadata = { ["foo"] = "bar" },
};
-AgentConversation conversation = await agentsClient.GetConversationClient().CreateConversationAsync(conversationOptions);
+ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(conversationOptions);
//
// Add items to an existing conversation to supplement the interaction state
//
string EXISTING_CONVERSATION_ID = conversation.Id;
-_ = await agentsClient.GetConversationClient().CreateConversationItemsAsync(
+_ = await projectClient.OpenAI.Conversations.CreateProjectConversationItemsAsync(
EXISTING_CONVERSATION_ID,
[ResponseItem.CreateSystemMessageItem("Story theme to use: department of licensing.")]);
@@ -53,11 +51,8 @@
// Use the agent and conversation in a response
//
-ResponseCreationOptions responseCreationOptions = new();
-responseCreationOptions.SetAgentReference(AGENT_NAME);
-responseCreationOptions.SetConversationReference(EXISTING_CONVERSATION_ID);
+ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(newAgentVersion, EXISTING_CONVERSATION_ID);
+List items = [ResponseItem.CreateUserMessageItem(inputTextContent: "Tell me a one-line story.")] ;
+ResponseResult response = await responseClient.CreateResponseAsync(items);
-List items = [ResponseItem.CreateUserMessageItem("Tell me a one-line story.")];
-OpenAIResponse response = await responseClient.CreateResponseAsync(items, responseCreationOptions);
-
-Console.WriteLine(response.GetOutputText());
\ No newline at end of file
+Console.WriteLine(response.GetOutputText());
diff --git a/samples/csharp/quickstart/quickstart-create-agent.cs b/samples/csharp/quickstart/quickstart-create-agent.cs
index 75b001d80..dab5d95e2 100644
--- a/samples/csharp/quickstart/quickstart-create-agent.cs
+++ b/samples/csharp/quickstart/quickstart-create-agent.cs
@@ -3,11 +3,11 @@
using Azure.Identity;
string projectEndpoint = Environment.GetEnvironmentVariable("PROJECT_ENDPOINT")
- ?? throw new InvalidOperationException("Missing environment variable 'PROJECT_ENDPOINT'");
+?? throw new InvalidOperationException("Missing environment variable 'PROJECT_ENDPOINT'");
string modelDeploymentName = Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME")
- ?? throw new InvalidOperationException("Missing environment variable 'MODEL_DEPLOYMENT_NAME'");
+?? throw new InvalidOperationException("Missing environment variable 'MODEL_DEPLOYMENT_NAME'");
string agentName = Environment.GetEnvironmentVariable("AGENT_NAME")
- ?? throw new InvalidOperationException("Missing environment variable 'AGENT_NAME'");
+?? throw new InvalidOperationException("Missing environment variable 'AGENT_NAME'");
AIProjectClient projectClient = new(new Uri(projectEndpoint), new AzureCliCredential());
@@ -20,9 +20,8 @@
agentName,
options: new(agentDefinition));
-List agentVersions = projectClient.Agents.GetAgentVersions(agentName);
+List agentVersions = [..projectClient.Agents.GetAgentVersions(agentName)];
foreach (AgentVersion agentVersion in agentVersions)
{
Console.WriteLine($"Agent: {agentVersion.Id}, Name: {agentVersion.Name}, Version: {agentVersion.Version}");
}
-
diff --git a/samples/csharp/quickstart/quickstart-responses.cs b/samples/csharp/quickstart/quickstart-responses.cs
index 1024a0b6d..d980fa97d 100644
--- a/samples/csharp/quickstart/quickstart-responses.cs
+++ b/samples/csharp/quickstart/quickstart-responses.cs
@@ -1,19 +1,18 @@
using Azure.AI.Projects;
using Azure.AI.Projects.OpenAI;
using Azure.Identity;
-using OpenAI;
using OpenAI.Responses;
#pragma warning disable OPENAI001
-string projectEndpoint = Environment.GetEnvironmentVariable("PROJECT_ENDPOINT")
- ?? throw new InvalidOperationException("Missing environment variable 'PROJECT_ENDPOINT'");
-string modelDeploymentName = Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME")
- ?? throw new InvalidOperationException("Missing environment variable 'MODEL_DEPLOYMENT_NAME'");
+string projectEndpoint = Environment.GetEnvironmentVariable("PROJECT_ENDPOINT")
+?? throw new InvalidOperationException("Missing environment variable 'PROJECT_ENDPOINT'");
+string modelDeploymentName = Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME")
+?? throw new InvalidOperationException("Missing environment variable 'MODEL_DEPLOYMENT_NAME'");
-AIProjectClient projectClient = new(new Uri(projectEndpoint ), new AzureCliCredential());
+AIProjectClient projectClient = new(new Uri(projectEndpoint), new AzureCliCredential());
ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName);
ResponseResult response = await responseClient.CreateResponseAsync("What is the size of France in square miles?");
-Console.WriteLine(response.GetOutputText());
\ No newline at end of file
+Console.WriteLine(response.GetOutputText());
From ec90e9a0a909e597bb436c5989f08c1fa988c09d Mon Sep 17 00:00:00 2001
From: nick863 <30440255+nick863@users.noreply.github.com>
Date: Fri, 30 Jan 2026 16:54:33 -0800
Subject: [PATCH 2/2] Fix
---
.../1-idea-to-prototype/Evaluate/nuget.config | 1 +
.../1-idea-to-prototype/ModernWorkplaceAssistant/nuget.config | 1 +
2 files changed, 2 insertions(+)
diff --git a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/nuget.config b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/nuget.config
index b2b33046f..abbb7d618 100644
--- a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/nuget.config
+++ b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/nuget.config
@@ -1,6 +1,7 @@
+
diff --git a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/nuget.config b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/nuget.config
index b2b33046f..abbb7d618 100644
--- a/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/nuget.config
+++ b/samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/nuget.config
@@ -1,6 +1,7 @@
+