AgenticRAG demonstrates an agentic Retrieval-Augmented Generation (RAG) pattern using Microsoft Semantic Kernel and Azure AI Search. The service exposes simple HTTP endpoints that accept a user prompt and return answers produced either by a "traditional" RAG prompt or by an agent-driven RAG flow.
- API: Minimal ASP.NET Web API in AgenticRAG/AgenticRAG/Program.cs and AgenticRAG/AgenticRAG/Controllers/RagController.cs.
- RAG service:
RagServiceimplements bothGenerateResponseUsingTraditionalRagandGenerateResponseUsingAgenticRag(AgenticRAG/AgenticRAG/Services/RagService/RagService.cs). - Vector search:
AzureSearchServicewraps Azure Cognitive Search + OpenAI embeddings for vector retrieval. - Plugin: Example
WeatherPluginshows how to import functionality into the kernel.
- Traditional RAG: fetches top context from Azure AI Search and prompts the model.
- Agentic RAG: uses Semantic Kernel agents for multi-step reasoning and tool invocation.
- CORS and static file hosting for quick front-end experiments.
Set these environment variables before running the app (names come from AgenticRAG/AgenticRAG/Constants/EnvVariables.cs):
AZURE_OPENAI_URL— Azure OpenAI endpoint URLAZURE_OPENAI_KEY— Azure OpenAI keyAZURE_AI_SEARCH_URL— Azure Cognitive Search endpointAZURE_AI_SEARCH_KEY— Azure Cognitive Search keyEMBEDDING_DEPLOYMENT_NAME— embedding deployment nameINDEX_NAME— search index nameGPT_DEPLOYMENT_NAME— chat / completion deployment name
- Open a terminal and set the environment variables (PowerShell example):
$env:AZURE_OPENAI_URL="https://your-openai-endpoint"
$env:AZURE_OPENAI_KEY="your-openai-key"
$env:AZURE_AI_SEARCH_URL="https://your-search-endpoint"
$env:AZURE_AI_SEARCH_KEY="your-search-key"
$env:EMBEDDING_DEPLOYMENT_NAME="your-embedding-deployment"
$env:INDEX_NAME="your-index-name"
$env:GPT_DEPLOYMENT_NAME="your-gpt-deployment"- Restore and run the API from the solution folder:
cd AgenticRAG
dotnet restore
dotnet run --project AgenticRAG/AgenticRAG.csprojThe API runs on the configured Kestrel port (HTTPS). In development the Swagger UI is enabled.
- POST /traditionalRag — body:
{ "prompt": "..." }— returns a JSONResponsewithContentcontaining the answer. - POST /agenticRag — body:
{ "prompt": "..." }— runs the agentic RAG flow and returnsContent.
Example curl (replace host and port):
curl -X POST https://localhost:5001/traditionalRag \
-H "Content-Type: application/json" \
-d '{"prompt":"Plan a 3-day trip to Paris focused on museums"}'- Startup and DI: AgenticRAG/AgenticRAG/Program.cs
- Controller: AgenticRAG/AgenticRAG/Controllers/RagController.cs
- RAG implementation: AgenticRAG/AgenticRAG/Services/RagService/RagService.cs
- Search integration: AgenticRAG/AgenticRAG/Services/SearchService.cs
- Replace the
WeatherPluginstub with real tool integrations as needed. - Add index population scripts for Azure Cognitive Search if you want reproducible demos.