Leanpub Header

Skip to main content

AI Engineering for .NET: Agents + RAG

Agents that cannot retrieve will hallucinate about your business. Retrieval that cannot act is just a search box. Get both halves of the .NET AI stack — the Microsoft Agent Framework, RAG, MCP, GraphRAG, evaluation gates, and Azure deployment. 1,268 pages, 44 chapters, 174 runnable projects in C# 14 and .NET 10.

Bought separately

$86.98

Minimum price

$54.99

$74.99

You pay

Author earns

$

Also available for 3 book credits with a Reader Membership

The following 2 books are included in this bundle...

These books have a total suggested price of $86.98. Get them now for only $54.99!
About

About

About the Bundle

Two books, one stack.

Building AI Agents with C# and .NET 10 teaches you to build and orchestrate agents on the Microsoft Agent Framework — tools, workflows, multi-agent systems, and the runtime concerns that decide whether an agent survives contact with production.

Production-Grade RAG with C# and .NET teaches you to ground them in your own data — embeddings, chunking, hybrid retrieval, reranking, GraphRAG, evaluation gates, prompt-injection defense, and an EU AI Act-aware Azure deployment.

They are two halves of the same problem. An agent without retrieval is fluent and confident about a business it knows nothing about. Retrieval without an agent stops at the search box — it finds the passage but never acts on it. Together you get a system that can look something up, reason about what it found, and then do something with it.

In the bundle:

  • 1,268 pages across 44 chapters, plus nine appendices in the RAG volume
  • Two companion repositories, 174 runnable projects — every sample compiles, every test passes on a clean clone
  • One architecture and one toolchain throughout: .NET 10, C# 14, the Microsoft Agent Framework 1.14, and Microsoft.Extensions.AI
  • A Python-to-.NET Rosetta Stone for readers arriving from LangChain or LlamaIndex

Both books are written for the same reader — a .NET developer with a few years of C# who wants to ship something real rather than a demo — and neither assumes you have read the other. Start with whichever problem is in front of you.

Most AI material is written for Python. This is the .NET path, end to end.

Books

About the Books

Building AI Agents with C# and .NET 10

A Developer’s First Guide to the Microsoft Agent Framework

Between the launch of ChatGPT and the GA release of the Microsoft Agent Framework in April 2026, a new class of .NET applications emerged: programs that hold a language model in one hand and a set of tools in the other, and decide for themselves how to string them together to reach a goal. The framework is ready. The guidance mostly isn't — it lives scattered across API docs, conference talks, and GitHub samples pinned to preview builds that broke last Tuesday.

Building AI Agents with C# and .NET 10 is the picture on the puzzle box. Nineteen chapters take you from your first LLM call in C# to a production-hosted, observability-instrumented, safety-filtered multi-agent system, all on the stable, generally available surface of Microsoft Agent Framework 1.14, .NET 10 LTS, and C# 14.

You will learn how to:

  • Build your first ChatClientAgent, give it a persona, and expose it over HTTP with Minimal API
  • Solve the amnesia problem with sessions, history providers, and context providers
  • Get typed C# records back from the model instead of strings you have to regex
  • Give agents tools and function calling, with human-in-the-loop approval for the dangerous ones
  • Build and consume Model Context Protocol (MCP) servers in C#
  • Ground answers in your own documents with retrieval-augmented generation
  • Send images, audio, and video to multimodal agents — and treat them as untrusted input
  • Coordinate specialists with multi-agent orchestration and typed workflow graphs
  • Host agents with ASP.NET Core and .NET Aspire, and instrument them with OpenTelemetry
  • Layer guardrails against the OWASP LLM Top 10, from input sanitization to critic agents
  • Package domain expertise as Agent Skills and measure quality with local and cloud evaluation

Along the way you build the Contoso FAQ agent, a small but real production system that grows chapter by chapter until it ships: hosted, observable, guarded, and evaluated.

What makes this book different is discipline. Every listing compiles and runs, and every one is paired with its expected console output, so you know what success looks like before you press F5. Chapters follow an Explain–Demonstrate–Practice rhythm. Exercises come in three tiers (Basic, Intermediate, Challenge) with full worked solutions in Appendix E. The companion repository — one solution, 120 runnable projects — works against Azure OpenAI, OpenAI, GitHub Models, or a local Ollama model with a single configuration change, and ships dedicated helpers for Anthropic and Microsoft Foundry.

Written for intermediate C# developers. No AI or machine learning background required: if you can write a class, use LINQ, and wire up dependency injection, you're ready. Coming from Semantic Kernel or AutoGen? Appendices B and C are your migration maps.

Buying for a team? Volume licenses are available from 3 copies, with team pricing up to 40% off for larger groups — one purchase, one invoice, a copy for everyone.

The companion code lives at https://github.com/RachidD68/building-ai-agents-with-csharp-and-dotnet-10

Production-Grade RAG with C# and .NET

Building Retrieval-Augmented Generation Systems with C#, the Microsoft Agent Framework, and Azure

Production-Grade RAG with C# and .NET is the complete guide to building Retrieval-Augmented Generation systems on the Microsoft stack — from an 80-line Hello World to a fully deployed, audited, EU AI Act-aware Azure pipeline.

Most RAG material is written for Python. This book is written for you: a .NET developer with a few years of C# experience who wants to ship something real with your company's data. Across seven parts, twenty-five chapters and 668 pages, you'll build Contoso SmartDocs, a running enterprise project that grows chapter by chapter into a production system spanning six document silos — powered by the Microsoft Agent Framework 1.14, Microsoft.Extensions.AI, Azure AI Search, Qdrant, Neo4j, and .NET 10 / C# 14.

You'll learn to:

  • Build the core pipeline component by component: embeddings, chunking with Anthropic's Contextual Retrieval, multimodal content, vector databases, indexing strategies, hybrid retrieval with RRF, reranking, and first-class SSE streaming
  • Add query intelligence: metadata filters, query construction, routing, and conversational multi-turn rewriting
  • Go beyond vectors with graph databases, hybrid storage, GraphRAG, LazyGraphRAG, and Vectorless RAG
  • Serve retrieval as a tool over the Model Context Protocol and orchestrate multi-agent RAG workflows with agentic memory
  • Ship it for real: a 100-query golden eval gate on every pull request, latency and cost optimization, drift and model migration, prompt-injection defense, grounded citations, EU AI Act audit logging, and a full Bicep-deployed Azure capstone

Every chapter ships runnable code in the companion repository. Every snippet traces to a specific file. Every sample compiles; all 458 tests pass on a clean clone. The architecture is deliberately clean — small, named interfaces with swappable implementations — so what you learn maps directly onto the system you need to build, not just the one in the book.

Nine appendices round it out: worked exercise solutions, a design-pattern flashcard set, a vector database comparison, embedding benchmarks, a Python-to-.NET Rosetta Stone for readers arriving from LangChain or LlamaIndex, a debugging decision tree, prompt patterns, and the math behind RAG.

This is the production-concerns RAG book the .NET ecosystem has been missing. If you can write C#, you can ship RAG.

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub