diff --git a/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/Program.cs b/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/Program.cs
index 70686f0..f68acb0 100644
--- a/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/Program.cs
+++ b/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/Program.cs
@@ -3,28 +3,23 @@
using System.ClientModel;
using Microsoft.Extensions.AI;
using Microsoft.Agents.AI;
+using Azure.AI.OpenAI;
using OpenAI;
using DotNetEnv;
// Load environment variables from .env file
-Env.Load("../../../../.env");
+Env.Load();
-// Get GitHub Models configuration from environment variables
-var github_endpoint = Environment.GetEnvironmentVariable("GITHUB_ENDPOINT")
+// Get Azure OpenAI configuration from environment variables
+var endpoint = Environment.GetEnvironmentVariable("GITHUB_ENDPOINT")
?? throw new InvalidOperationException("GITHUB_ENDPOINT is required");
-var github_model_id = Environment.GetEnvironmentVariable("GITHUB_MODEL_ID") ?? "gpt-4o-mini";
-var github_token = Environment.GetEnvironmentVariable("GITHUB_TOKEN")
+var model_id = Environment.GetEnvironmentVariable("GITHUB_MODEL_ID") ?? "gpt-4o-mini";
+var api_key = Environment.GetEnvironmentVariable("GITHUB_TOKEN")
?? throw new InvalidOperationException("GITHUB_TOKEN is required");
-// Configure OpenAI client for GitHub Models
-var openAIOptions = new OpenAIClientOptions()
-{
- Endpoint = new Uri(github_endpoint)
-};
-
// Create AI Agent with custom tool
-AIAgent agent = new OpenAIClient(new ApiKeyCredential(github_token), openAIOptions)
- .GetChatClient(github_model_id)
+AIAgent agent = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(api_key))
+ .GetChatClient(model_id)
.AsIChatClient()
.AsAIAgent(
name: "TravelAgent",
diff --git a/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/dotnet-agent-framework-travelagent.csproj b/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/dotnet-agent-framework-travelagent.csproj
index 7b3d90f..429ab2d 100644
--- a/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/dotnet-agent-framework-travelagent.csproj
+++ b/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/dotnet-agent-framework-travelagent.csproj
@@ -10,14 +10,15 @@
+
-
-
+
+
diff --git a/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/dotnet-agent-framework-travelagent.sln b/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/dotnet-agent-framework-travelagent.sln
new file mode 100644
index 0000000..a1a1410
--- /dev/null
+++ b/00.ForBeginners/01-intro-to-ai-agents/code_samples/dotnet-agent-framework-travelagent/dotnet-agent-framework-travelagent.sln
@@ -0,0 +1,24 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.2.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-agent-framework-travelagent", "dotnet-agent-framework-travelagent.csproj", "{84534CF9-905D-F1F7-BE0B-AFD013A9C1AD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {84534CF9-905D-F1F7-BE0B-AFD013A9C1AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {84534CF9-905D-F1F7-BE0B-AFD013A9C1AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {84534CF9-905D-F1F7-BE0B-AFD013A9C1AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {84534CF9-905D-F1F7-BE0B-AFD013A9C1AD}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1C76B464-0241-4BFB-B5D1-B18BA27355F2}
+ EndGlobalSection
+EndGlobal
diff --git a/00.ForBeginners/02-explore-agentic-frameworks/code_samples/dotnet-agent-framework-basicagent/Program.cs b/00.ForBeginners/02-explore-agentic-frameworks/code_samples/dotnet-agent-framework-basicagent/Program.cs
index a641bf5..9ad3fef 100644
--- a/00.ForBeginners/02-explore-agentic-frameworks/code_samples/dotnet-agent-framework-basicagent/Program.cs
+++ b/00.ForBeginners/02-explore-agentic-frameworks/code_samples/dotnet-agent-framework-basicagent/Program.cs
@@ -3,7 +3,8 @@
using System.ClientModel;
using Microsoft.Extensions.AI;
using Microsoft.Agents.AI;
-using OpenAI;
+using Azure;
+using Azure.AI.OpenAI;
using DotNetEnv;
// Load environment variables from .env file
@@ -16,11 +17,6 @@
var github_token = Environment.GetEnvironmentVariable("GITHUB_TOKEN")
?? throw new InvalidOperationException("GITHUB_TOKEN is not set.");
-// Configure OpenAI client for GitHub Models
-var openAIOptions = new OpenAIClientOptions()
-{
- Endpoint = new Uri(github_endpoint)
-};
// Agent Tool: Random Destination Generator
[Description("Provides a random vacation destination.")]
@@ -45,7 +41,7 @@ static string GetRandomDestination()
}
// Create AI Agent with basic instructions and tool
-AIAgent agent = new OpenAIClient(new ApiKeyCredential(github_token), openAIOptions)
+AIAgent agent = new AzureOpenAIClient(new Uri(github_endpoint), new AzureKeyCredential(github_token))
.GetChatClient(github_model_id)
.AsIChatClient()
.AsAIAgent(
diff --git a/00.ForBeginners/02-explore-agentic-frameworks/code_samples/dotnet-agent-framework-basicagent/dotnet-agent-framework-basicagent.csproj b/00.ForBeginners/02-explore-agentic-frameworks/code_samples/dotnet-agent-framework-basicagent/dotnet-agent-framework-basicagent.csproj
index fe9a539..c271625 100644
--- a/00.ForBeginners/02-explore-agentic-frameworks/code_samples/dotnet-agent-framework-basicagent/dotnet-agent-framework-basicagent.csproj
+++ b/00.ForBeginners/02-explore-agentic-frameworks/code_samples/dotnet-agent-framework-basicagent/dotnet-agent-framework-basicagent.csproj
@@ -10,14 +10,15 @@
+
-
-
+
+
diff --git a/00.ForBeginners/05-agentic-rag/code_samples/dotnet-agent-framework-msfoundry-file-search/Program.cs b/00.ForBeginners/05-agentic-rag/code_samples/dotnet-agent-framework-msfoundry-file-search/Program.cs
index 2ca52e2..76d26c9 100644
--- a/00.ForBeginners/05-agentic-rag/code_samples/dotnet-agent-framework-msfoundry-file-search/Program.cs
+++ b/00.ForBeginners/05-agentic-rag/code_samples/dotnet-agent-framework-msfoundry-file-search/Program.cs
@@ -1,4 +1,7 @@
using System.ClientModel;
+using System.ClientModel.Primitives;
+using System.IO;
+using System.Reflection;
using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
@@ -9,7 +12,7 @@
using DotNetEnv;
-Env.Load("/Users/lokinfey/Desktop/AOAI/Foundry/Agent-Framework-Samples/.env");
+Env.Load("../../../../.env");
var endpoint = Environment.GetEnvironmentVariable("AZURE_AI_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("AZURE_AI_PROJECT_ENDPOINT is not set.");
var deploymentName = Environment.GetEnvironmentVariable("AZURE_AI_MODEL_DEPLOYMENT_NAME") ?? "gpt-4o-mini";
@@ -22,9 +25,18 @@
// Upload the file that contains the data to be used for RAG to the Foundry service.
OpenAIFileClient fileClient = openAIClient.GetOpenAIFileClient();
-ClientResult uploadResult = await fileClient.UploadFileAsync(
- filePath: "../document.md",
- purpose: FileUploadPurpose.Assistants);
+ClientResult uploadResult;
+try
+{
+ uploadResult = await fileClient.UploadFileAsync(
+ filePath: "../document.md",
+ purpose: FileUploadPurpose.Assistants);
+}
+catch (ClientResultException ex)
+{
+ LogDetailedClientError("File upload failed", ex);
+ throw;
+}
#pragma warning disable OPENAI001
VectorStoreClient vectorStoreClient = openAIClient.GetVectorStoreClient();
@@ -50,5 +62,56 @@ Do not answer from general knowledge or reasoning. Do not make assumptions or ge
AgentSession session = await agent.CreateSessionAsync();
-Console.WriteLine(await agent.RunAsync("Can you explain Contoso's travel insurance coverage?", session));
+//Console.WriteLine(await agent.RunAsync("Can you explain Contoso's travel insurance coverage?", session));
+Console.WriteLine(await agent.RunAsync("What is the weather in Ohio today?", session));
+
+static void LogDetailedClientError(string context, ClientResultException ex)
+{
+ Console.Error.WriteLine($"[Client Error] {context}");
+ Console.Error.WriteLine($"Status: {ex.Status}");
+ Console.Error.WriteLine($"Message: {ex.Message}");
+ var responseBody = TryExtractResponseBody(ex);
+ if (!string.IsNullOrWhiteSpace(responseBody))
+ {
+ Console.Error.WriteLine("Server response body:");
+ Console.Error.WriteLine(responseBody);
+ }
+}
+
+static string? TryExtractResponseBody(ClientResultException ex)
+{
+ try
+ {
+ var responseField = typeof(ClientResultException).GetField("_response", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (responseField?.GetValue(ex) is PipelineResponse response)
+ {
+ var stream = response.ContentStream;
+ if (stream == null)
+ {
+ return null;
+ }
+
+ if (stream.CanSeek)
+ {
+ stream.Position = 0;
+ }
+
+ using var reader = new StreamReader(stream, leaveOpen: true);
+ var body = reader.ReadToEnd();
+
+ if (stream.CanSeek)
+ {
+ stream.Position = 0;
+ }
+
+ return body;
+ }
+ }
+ catch
+ {
+ // Ignore reflection or IO errors when extracting diagnostics.
+ }
+
+ return null;
+}
diff --git a/00.ForBeginners/05-agentic-rag/code_samples/dotnet-agent-framework-msfoundry-file-search/dotnet-agent-framework-msfoundry-file-search.csproj b/00.ForBeginners/05-agentic-rag/code_samples/dotnet-agent-framework-msfoundry-file-search/dotnet-agent-framework-msfoundry-file-search.csproj
index 767aa18..2c5107f 100644
--- a/00.ForBeginners/05-agentic-rag/code_samples/dotnet-agent-framework-msfoundry-file-search/dotnet-agent-framework-msfoundry-file-search.csproj
+++ b/00.ForBeginners/05-agentic-rag/code_samples/dotnet-agent-framework-msfoundry-file-search/dotnet-agent-framework-msfoundry-file-search.csproj
@@ -10,18 +10,15 @@
-
+
-
-
-
+
+
+
-
-
-
-
-
+
+
diff --git a/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Models/Plan.cs b/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Models/Plan.cs
index 72fcd28..3acf2ad 100644
--- a/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Models/Plan.cs
+++ b/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Models/Plan.cs
@@ -1,6 +1,3 @@
-using System;
-using System.ClientModel;
-using System.Text.Json;
using System.Text.Json.Serialization;
public class Plan
{
diff --git a/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Models/TravelPlan.cs b/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Models/TravelPlan.cs
index 4e9842d..069c046 100644
--- a/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Models/TravelPlan.cs
+++ b/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Models/TravelPlan.cs
@@ -1,6 +1,4 @@
-using System;
-using System.ClientModel;
-using System.Text.Json;
+using System.Collections.Generic;
using System.Text.Json.Serialization;
public class TravelPlan
{
@@ -8,5 +6,5 @@ public class TravelPlan
public string? Main_task { get; set; }
[JsonPropertyName("subtasks")]
- public IList Subtasks { get; set; }
+ public IList Subtasks { get; set; } = new List();
}
\ No newline at end of file
diff --git a/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Program.cs b/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Program.cs
index 36d6358..5d9dbd4 100644
--- a/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Program.cs
+++ b/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/Program.cs
@@ -1,29 +1,24 @@
using System;
-using System.ClientModel;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-using Microsoft.Extensions.AI;
-using Microsoft.Agents.AI;
-using OpenAI;
+using Azure;
+using Azure.AI.OpenAI;
using DotNetEnv;
+using Microsoft.Agents.AI;
+using Microsoft.Extensions.AI;
// Load environment variables from .env file
Env.Load("../../../../.env");
-// Get GitHub Models configuration from environment variables
-var github_endpoint = Environment.GetEnvironmentVariable("GITHUB_ENDPOINT")
- ?? throw new InvalidOperationException("GITHUB_ENDPOINT is not set.");
-var github_model_id = Environment.GetEnvironmentVariable("GITHUB_MODEL_ID") ?? "gpt-4o-mini";
-var github_token = Environment.GetEnvironmentVariable("GITHUB_TOKEN")
- ?? throw new InvalidOperationException("GITHUB_TOKEN is not set.");
+// Get Azure OpenAI configuration from environment variables
+var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")
+ ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
+var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT")
+ ?? throw new InvalidOperationException("AZURE_OPENAI_DEPLOYMENT is not set.");
+var apiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_KEY")
+ ?? throw new InvalidOperationException("AZURE_OPENAI_KEY is not set.");
-// Configure OpenAI client for GitHub Models
-var openAIOptions = new OpenAIClientOptions()
-{
- Endpoint = new Uri(github_endpoint)
-};
-var openAIClient = new OpenAIClient(new ApiKeyCredential(github_token), openAIOptions);
+// Configure Azure OpenAI client for the specified deployment
+var azureOpenAIClient = new AzureOpenAIClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
// Planning agent configuration
const string AGENT_NAME = "TravelPlanAgent";
@@ -50,6 +45,9 @@ Your job is to decide which agents to run based on the user's request.
}
};
-AIAgent agent = openAIClient.GetChatClient(github_model_id).AsIChatClient().AsAIAgent(agentOptions);
+AIAgent agent = azureOpenAIClient
+ .GetChatClient(deploymentName)
+ .AsIChatClient()
+ .AsAIAgent(agentOptions);
Console.WriteLine(await agent.RunAsync("Create a travel plan for a family of 4, with 2 kids, from Singapore to Melbourne"));
diff --git a/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/dotnet-agent-framrwork-ghmodel-planningdesign.csproj b/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/dotnet-agent-framrwork-ghmodel-planningdesign.csproj
index 831dccf..d4ae225 100644
--- a/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/dotnet-agent-framrwork-ghmodel-planningdesign.csproj
+++ b/00.ForBeginners/07-planning-design/code_samples/dotnet-agent-framrwork-ghmodel-planningdesign/dotnet-agent-framrwork-ghmodel-planningdesign.csproj
@@ -10,14 +10,11 @@
+
+
+
-
-
-
-
-
-
diff --git a/02.CreateYourFirstAgent/code_samples/dotNET/dotnet-travelagent-ghmodel/Program.cs b/02.CreateYourFirstAgent/code_samples/dotNET/dotnet-travelagent-ghmodel/Program.cs
index 9982074..8233b1f 100644
--- a/02.CreateYourFirstAgent/code_samples/dotNET/dotnet-travelagent-ghmodel/Program.cs
+++ b/02.CreateYourFirstAgent/code_samples/dotNET/dotnet-travelagent-ghmodel/Program.cs
@@ -3,7 +3,7 @@
using System.ClientModel;
using Microsoft.Extensions.AI;
using Microsoft.Agents.AI;
-using OpenAI;
+using Azure.AI.OpenAI;
using DotNetEnv;
// Load environment variables from .env file
diff --git a/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/.vscode/launch.json b/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/.vscode/launch.json
new file mode 100644
index 0000000..c1d3222
--- /dev/null
+++ b/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/.vscode/launch.json
@@ -0,0 +1,16 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": ".NET: Agent Framework",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ "program": "${workspaceFolder}/bin/Debug/net10.0/01-dotnet-agent-framework-aoai.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}",
+ "console": "integratedTerminal",
+ "stopAtEntry": false
+ }
+ ]
+}
diff --git a/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/.vscode/tasks.json b/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/.vscode/tasks.json
new file mode 100644
index 0000000..f019f5a
--- /dev/null
+++ b/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/.vscode/tasks.json
@@ -0,0 +1,21 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "type": "process",
+ "command": "dotnet",
+ "args": [
+ "build",
+ "${workspaceFolder}/01-dotnet-agent-framework-aoai.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:Summary"
+ ],
+ "problemMatcher": "$msCompile",
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ }
+ }
+ ]
+}
diff --git a/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/01-dotnet-agent-framework-aoai.csproj b/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/01-dotnet-agent-framework-aoai.csproj
index 3ee98a1..bc45e10 100644
--- a/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/01-dotnet-agent-framework-aoai.csproj
+++ b/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/01-dotnet-agent-framework-aoai.csproj
@@ -13,11 +13,8 @@
-
-
-
-
-
+
+
diff --git a/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/01-dotnet-agent-framework-aoai.sln b/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/01-dotnet-agent-framework-aoai.sln
new file mode 100644
index 0000000..359f32e
--- /dev/null
+++ b/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/01-dotnet-agent-framework-aoai.sln
@@ -0,0 +1,24 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.2.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01-dotnet-agent-framework-aoai", "01-dotnet-agent-framework-aoai.csproj", "{C9B96716-A1B5-6CDE-8D88-37E505C868BB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C9B96716-A1B5-6CDE-8D88-37E505C868BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C9B96716-A1B5-6CDE-8D88-37E505C868BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C9B96716-A1B5-6CDE-8D88-37E505C868BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C9B96716-A1B5-6CDE-8D88-37E505C868BB}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {EE11B157-DA8D-4182-A116-0AFB38CA683A}
+ EndGlobalSection
+EndGlobal
diff --git a/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/Program.cs b/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/Program.cs
index 6669222..398f068 100644
--- a/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/Program.cs
+++ b/03.ExploerAgentFramework/code_samples/dotNET/01-dotnet-agent-framework-aoai/Program.cs
@@ -4,10 +4,18 @@
using OpenAI.Chat;
using DotNetEnv;
-Env.Load("/Users/lokinfey/Desktop/AOAI/Foundry/Agent-Framework-Samples/.env");
+var envFilePath = FindNearestEnvFile();
+if (envFilePath is not null)
+{
+ Env.Load(envFilePath);
+}
+else
+{
+ Console.WriteLine("No .env file found; relying on existing environment variables.");
+}
var aoai_endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
-var aoai_model_id = Environment.GetEnvironmentVariable("AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME") ?? "gpt-4.1-mini";
+var aoai_model_id = Environment.GetEnvironmentVariable("AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME") ?? "gpt-4o";
Console.WriteLine($"Using Azure OpenAI Endpoint: {aoai_endpoint}");
Console.WriteLine($"Using Azure OpenAI Model Deployment: {aoai_model_id}");
@@ -27,4 +35,22 @@
}
+static string? FindNearestEnvFile()
+{
+ var currentDirectory = AppContext.BaseDirectory;
+ while (!string.IsNullOrEmpty(currentDirectory))
+ {
+ var candidate = Path.Combine(currentDirectory, ".env");
+ if (File.Exists(candidate))
+ {
+ return candidate;
+ }
+
+ currentDirectory = Directory.GetParent(currentDirectory)?.FullName;
+ }
+
+ return null;
+}
+
+
diff --git a/04.Tools/code_samples/dotNET/msfoundry/01-dotnet-agent-framework-msfoundry-vision/01-dotnet-agent-framework-msfoundry-vision.csproj b/04.Tools/code_samples/dotNET/msfoundry/01-dotnet-agent-framework-msfoundry-vision/01-dotnet-agent-framework-msfoundry-vision.csproj
index 9013eb6..ed20c48 100644
--- a/04.Tools/code_samples/dotNET/msfoundry/01-dotnet-agent-framework-msfoundry-vision/01-dotnet-agent-framework-msfoundry-vision.csproj
+++ b/04.Tools/code_samples/dotNET/msfoundry/01-dotnet-agent-framework-msfoundry-vision/01-dotnet-agent-framework-msfoundry-vision.csproj
@@ -12,15 +12,12 @@
-
-
-
+
+
+
-
-
-
-
-
+
+
diff --git a/04.Tools/code_samples/dotNET/msfoundry/02-dotnet-agent-framework-msfoundry-code-interpreter/02-dotnet-agent-framework-msfoundry-code-interpreter.csproj b/04.Tools/code_samples/dotNET/msfoundry/02-dotnet-agent-framework-msfoundry-code-interpreter/02-dotnet-agent-framework-msfoundry-code-interpreter.csproj
index b509cd2..7437238 100644
--- a/04.Tools/code_samples/dotNET/msfoundry/02-dotnet-agent-framework-msfoundry-code-interpreter/02-dotnet-agent-framework-msfoundry-code-interpreter.csproj
+++ b/04.Tools/code_samples/dotNET/msfoundry/02-dotnet-agent-framework-msfoundry-code-interpreter/02-dotnet-agent-framework-msfoundry-code-interpreter.csproj
@@ -17,11 +17,8 @@
-
-
-
-
-
+
+
diff --git a/TempInspect/Program.cs b/TempInspect/Program.cs
new file mode 100644
index 0000000..c4e6951
--- /dev/null
+++ b/TempInspect/Program.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Linq;
+
+var type = Type.GetType("System.ClientModel.ClientResultException, System.ClientModel");
+Console.WriteLine(type);
+foreach (var prop in type.GetProperties())
+{
+ Console.WriteLine($"Property: {prop.Name} - {prop.PropertyType}");
+}
+foreach (var field in type.GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance))
+{
+ Console.WriteLine($"Field: {field.Name} - {field.FieldType}");
+}
diff --git a/TempInspect/TempInspect.csproj b/TempInspect/TempInspect.csproj
new file mode 100644
index 0000000..60c0fb3
--- /dev/null
+++ b/TempInspect/TempInspect.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+