.NET RAG Chat
Retrieval-Augmented Generation pipeline in C# with Azure OpenAI and Azure AI Search
About This Project
Build a production RAG (Retrieval-Augmented Generation) system entirely in .NET using Azure OpenAI for LLM completions, Azure AI Search for vector retrieval, and Semantic Kernel for orchestration. Upload documents, index them with embeddings, and chat with your data — with source citations on every answer.
What You'll Learn
Key Features
Setup Guide
Clone and configure Azure credentials
Clone the repo and set Azure keys in user secrets.
git clone https://github.com/asmanasir/dotnet-rag.git cd dotnet-rag dotnet user-secrets set "AzureOpenAI:Endpoint" "https://your-instance.openai.azure.com/" dotnet user-secrets set "AzureOpenAI:ApiKey" "your-key" dotnet user-secrets set "AzureOpenAI:DeploymentName" "gpt-4o" dotnet user-secrets set "AzureOpenAI:EmbeddingDeployment" "text-embedding-3-small" dotnet user-secrets set "AzureSearch:Endpoint" "https://your-search.search.windows.net" dotnet user-secrets set "AzureSearch:ApiKey" "your-key"
Start PostgreSQL with Docker
PostgreSQL stores conversation history and document metadata.
docker-compose up -d db dotnet ef database update
Install frontend dependencies
The React chat UI is in the /frontend directory.
cd frontend && npm install && cd ..
Running the Project
Start the API and frontend
Run both in separate terminals.
# Terminal 1 — API dotnet run --project src/RagChat.Api # Terminal 2 — React UI cd frontend && npm run dev
Upload a document and chat
Upload a PDF, wait for indexing, then ask questions about it.
# Upload a document curl -X POST http://localhost:5000/api/documents \ -F "file=@./sample.pdf" # Wait for indexing (~10 seconds), then open the chat UI # http://localhost:3000
Project Info
Tech Stack
Prerequisites
- .NET 8 SDK installed
- Azure subscription with Azure OpenAI access approved
- Azure AI Search instance (free tier works)
- Docker Desktop installed
- Node.js 18+ for the React frontend
Learnixo
Project Author
RAG is the most requested AI pattern in enterprise .NET shops right now. This project shows the full pipeline — document ingestion, embedding, vector search, and grounded generation — using the Semantic Kernel stack that .NET teams are adopting.