From ed198ed84a76baed170c5377e7aed3547ec9b745 Mon Sep 17 00:00:00 2001 From: Maryanne Gichohi Date: Thu, 9 Apr 2026 17:51:33 +0300 Subject: [PATCH 1/5] Add .NET sample chat agent app --- examples/DotNetCore/ChatAgent | 1 + 1 file changed, 1 insertion(+) create mode 160000 examples/DotNetCore/ChatAgent diff --git a/examples/DotNetCore/ChatAgent b/examples/DotNetCore/ChatAgent new file mode 160000 index 00000000..834eee9c --- /dev/null +++ b/examples/DotNetCore/ChatAgent @@ -0,0 +1 @@ +Subproject commit 834eee9cd59272a6535ecb20f59887b4835ed90f From 6dd62134d9f7255b385c9ee908086447bcb3c57b Mon Sep 17 00:00:00 2001 From: MaryanneNjeri Date: Thu, 9 Apr 2026 17:59:58 +0300 Subject: [PATCH 2/5] Update ChatAgent submodule with new example --- examples/DotNetCore/ChatAgent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/DotNetCore/ChatAgent b/examples/DotNetCore/ChatAgent index 834eee9c..eb380ab8 160000 --- a/examples/DotNetCore/ChatAgent +++ b/examples/DotNetCore/ChatAgent @@ -1 +1 @@ -Subproject commit 834eee9cd59272a6535ecb20f59887b4835ed90f +Subproject commit eb380ab8c2faccfc0a858061c343e606ee26b31f From 5f2ff517248e359de05977b4c3fe8d403a8dddb4 Mon Sep 17 00:00:00 2001 From: MaryanneNjeri Date: Thu, 9 Apr 2026 21:17:30 +0300 Subject: [PATCH 3/5] Add .NET sample app --- examples/DotNetCore/ChatAgent | 1 - .../ChatAgent/ChatAgent/ChatAgent.csproj | 20 ++++ .../DotNetCore/ChatAgent/ChatAgent/Program.cs | 62 ++++++++++++ examples/DotNetCore/ChatAgent/README.md | 94 +++++++++++++++++++ 4 files changed, 176 insertions(+), 1 deletion(-) delete mode 160000 examples/DotNetCore/ChatAgent create mode 100644 examples/DotNetCore/ChatAgent/ChatAgent/ChatAgent.csproj create mode 100644 examples/DotNetCore/ChatAgent/ChatAgent/Program.cs create mode 100644 examples/DotNetCore/ChatAgent/README.md diff --git a/examples/DotNetCore/ChatAgent b/examples/DotNetCore/ChatAgent deleted file mode 160000 index eb380ab8..00000000 --- a/examples/DotNetCore/ChatAgent +++ /dev/null @@ -1 +0,0 @@ -Subproject commit eb380ab8c2faccfc0a858061c343e606ee26b31f diff --git a/examples/DotNetCore/ChatAgent/ChatAgent/ChatAgent.csproj b/examples/DotNetCore/ChatAgent/ChatAgent/ChatAgent.csproj new file mode 100644 index 00000000..f615f08a --- /dev/null +++ b/examples/DotNetCore/ChatAgent/ChatAgent/ChatAgent.csproj @@ -0,0 +1,20 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + + + + + + + diff --git a/examples/DotNetCore/ChatAgent/ChatAgent/Program.cs b/examples/DotNetCore/ChatAgent/ChatAgent/Program.cs new file mode 100644 index 00000000..61ca58eb --- /dev/null +++ b/examples/DotNetCore/ChatAgent/ChatAgent/Program.cs @@ -0,0 +1,62 @@ +using Azure.Core; +using Azure.Identity; +using Microsoft.Agents.AI; +using Microsoft.Extensions.AI; +using Azure.AI.Projects; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration.AzureAppConfiguration; + +TokenCredential credential = new AzureCliCredential(); +IConfigurationRefresher refresher = null; + +// Load configuration from Azure App Configuration +IConfiguration configuration = new ConfigurationBuilder() + .AddAzureAppConfiguration(options => + { + Uri endpoint = new(Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_ENDPOINT") ?? + throw new InvalidOperationException("The environment variable 'AZURE_APPCONFIGURATION_ENDPOINT' is not set or is empty")); + options.Connect(endpoint, credential) + .Select("ChatAgent:*") + .ConfigureRefresh(refreshOptions => + { + refreshOptions.RegisterAll(); + }); + refresher = options.GetRefresher(); + }).Build(); + +var endpoint = configuration["ChatAgent:ProjectEndpoint"]; +var deploymentName = configuration["ChatAgent:DeploymentName"]; + +IChatClient chatClient = new AIProjectClient( + new Uri(endpoint), credential) + .GetProjectOpenAIClient() + .GetProjectResponsesClient() + .AsIChatClient(); + +var agentSpec = configuration["ChatAgent:Spec"]; + +var agentFactory = new ChatClientPromptAgentFactory(chatClient); + +AIAgent agent = await agentFactory.CreateFromYamlAsync(agentSpec); + +while (true) +{ + Console.WriteLine("How can I help? (type 'quit' to exit)"); + + Console.Write("User: "); + + var userInput = Console.ReadLine(); + + if (userInput?.Trim().ToLower() == "quit") + { + break; + } + + var response = await agent.RunAsync(userInput); + + Console.WriteLine($"Agent response: {response}"); + Console.WriteLine("Press enter to continue..."); + Console.ReadLine(); +} + +Console.WriteLine("Goodbye!"); \ No newline at end of file diff --git a/examples/DotNetCore/ChatAgent/README.md b/examples/DotNetCore/ChatAgent/README.md new file mode 100644 index 00000000..8a484d8a --- /dev/null +++ b/examples/DotNetCore/ChatAgent/README.md @@ -0,0 +1,94 @@ +# Azure App Configuration - AI Agent chat application + +This sample demonstrates using Azure App Configuration to load agent YAML specifications that define AI agent behavior, prompts, and model configurations for a chat application. + +## Features +- Integrates with Azure AI Agent Framework to create a conversational AI agent +- Loads agent YAML specifications from Azure App Configuration. + +## Prerequisites + +- .NET 10 SDK +- An Azure subscription with: + - An Azure App Configuration store + - An Azure AI project with a deployed gpt-5 model. +- User has **App Configuration Reader** role assigned for the Azure App Configuration resource. +- User has **Azure AI User** role assigned for the Azure AI project. + +## Setup + +1. Clone the repository and navigate to the `examples\DotNetCore\ChatAgent` directory: + ```bash + git clone https://github.com/Azure/AppConfiguration.git + cd examples\DotNetCore\ChatAgent\ChatAgent + ``` + +1. Install the required packages: + + ```bash + dotnet restore + ``` + +1. Add the following key-values to your Azure App Configuration store. + + | Key | Value | + |-----|-------| + | ChatAgent:Spec | _See YAML below_ | + | ChatAgent:ProjectEndpoint | _Your Azure AI project endpoint_ | + | ChatAgent:DeploymentName| gpt-5| + + **YAML specification for _ChatAgent:Spec_** + ```yaml + kind: Prompt + name: ChatAgent + description: Agent example with web search + instructions: You are a helpful assistant with access to web search. + model: + id: gpt-5 + connection: + kind: remote + tools: + - kind: webSearch + name: WebSearchTool + description: Search the web for live information. + ``` + +1. Set the required environment variable: + + If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect: + + ```cmd + setx AZURE_APPCONFIGURATION_ENDPOINT "" + ``` + + If you use PowerShell, run the following command: + ```powershell + $Env:AZURE_APPCONFIGURATION_ENDPOINT="" + ``` + + If you use macOS or Linux run the following command: + ```bash + export AZURE_APPCONFIGURATION_ENDPOINT='' + ``` + +## Run the Application + +1. Start the console application: + + ```cmd + dotnet run + ``` + +1. Type the message "What is the weather in Seattle today?" when prompted with "How can I help?" and then press the Enter key + + ```Output + How can I help? (type 'quit' to exit) + User: What is the weather in Seattle today ? + Agent response: Seattle weather for today (Thursday, April 9, 2026): + + - Current conditions (as of ~10:48 AM PDT): 55°F, sunny. Wind N 6 mph (gusts 7), humidity 55%, pressure 30.05 in. ([wunderground.com](https://www.wunderground.com/weather/us/wa/seattle)) + - Today’s forecast: Mostly sunny and mild. High around 64–65°F; tonight’s low near 43–44°F. Very low chance of precipitation and light winds. ([wunderground.com](https://www.wunderground.com/weather/us/wa/seattle)) + + Want the hour‑by‑hour forecast or weekend outlook? + Press enter to continue... + ``` \ No newline at end of file From 32a9e5581dc352e1c6952b80c34df5bccaa921d4 Mon Sep 17 00:00:00 2001 From: MaryanneNjeri Date: Thu, 9 Apr 2026 21:23:34 +0300 Subject: [PATCH 4/5] Update folder --- examples/DotNetCore/ChatAgent/{ChatAgent => }/ChatAgent.csproj | 0 examples/DotNetCore/ChatAgent/{ChatAgent => }/Program.cs | 0 examples/DotNetCore/ChatAgent/README.md | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename examples/DotNetCore/ChatAgent/{ChatAgent => }/ChatAgent.csproj (100%) rename examples/DotNetCore/ChatAgent/{ChatAgent => }/Program.cs (100%) diff --git a/examples/DotNetCore/ChatAgent/ChatAgent/ChatAgent.csproj b/examples/DotNetCore/ChatAgent/ChatAgent.csproj similarity index 100% rename from examples/DotNetCore/ChatAgent/ChatAgent/ChatAgent.csproj rename to examples/DotNetCore/ChatAgent/ChatAgent.csproj diff --git a/examples/DotNetCore/ChatAgent/ChatAgent/Program.cs b/examples/DotNetCore/ChatAgent/Program.cs similarity index 100% rename from examples/DotNetCore/ChatAgent/ChatAgent/Program.cs rename to examples/DotNetCore/ChatAgent/Program.cs diff --git a/examples/DotNetCore/ChatAgent/README.md b/examples/DotNetCore/ChatAgent/README.md index 8a484d8a..79f98fa5 100644 --- a/examples/DotNetCore/ChatAgent/README.md +++ b/examples/DotNetCore/ChatAgent/README.md @@ -20,7 +20,7 @@ This sample demonstrates using Azure App Configuration to load agent YAML specif 1. Clone the repository and navigate to the `examples\DotNetCore\ChatAgent` directory: ```bash git clone https://github.com/Azure/AppConfiguration.git - cd examples\DotNetCore\ChatAgent\ChatAgent + cd examples\DotNetCore\ChatAgent ``` 1. Install the required packages: From b21bd5e2d0c34edcea8e5aed1c7d36094ec5f72f Mon Sep 17 00:00:00 2001 From: MaryanneNjeri Date: Thu, 9 Apr 2026 21:56:18 +0300 Subject: [PATCH 5/5] Suppress warning --- examples/DotNetCore/ChatAgent/ChatAgent.csproj | 1 + examples/DotNetCore/ChatAgent/README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/DotNetCore/ChatAgent/ChatAgent.csproj b/examples/DotNetCore/ChatAgent/ChatAgent.csproj index f615f08a..e1e679a1 100644 --- a/examples/DotNetCore/ChatAgent/ChatAgent.csproj +++ b/examples/DotNetCore/ChatAgent/ChatAgent.csproj @@ -3,6 +3,7 @@ Exe net10.0 + $(NoWarn);OPENAI001 enable enable diff --git a/examples/DotNetCore/ChatAgent/README.md b/examples/DotNetCore/ChatAgent/README.md index 79f98fa5..c312303b 100644 --- a/examples/DotNetCore/ChatAgent/README.md +++ b/examples/DotNetCore/ChatAgent/README.md @@ -35,7 +35,7 @@ This sample demonstrates using Azure App Configuration to load agent YAML specif |-----|-------| | ChatAgent:Spec | _See YAML below_ | | ChatAgent:ProjectEndpoint | _Your Azure AI project endpoint_ | - | ChatAgent:DeploymentName| gpt-5| + | ChatAgent:DeploymentName| gpt-5 | **YAML specification for _ChatAgent:Spec_** ```yaml