Black Friday Deals For Authors Are On Now!

Leanpub Header

Skip to main content

AI Engineering for .NET: Agents + RAG (Second Editions)

An agent that can't retrieve will make things up about your business. Retrieval that can't act stops at the search box. Get both second editions in C# and .NET 10 on Microsoft Agent Framework 1.28: authorized actions, durable workflows, permission-aware RAG, hybrid retrieval, evaluation gates. 1,526 pages, 53 chapters, two companion repositories.

4. Meta description (153 characters, under the roughly 160 where search engines cut it off)

Two second editions: build reliable AI agents with Microsoft Agent Framework 1.28, then ground them with production RAG. C#, .NET 10, MCP. Code included.

Where the figures come from

  • Pages: 701 for the agents book (the final PDF without its two cover pages) plus 825 for the RAG book (the page count in its second-edition settings, from the 2026-11-28 build).
  • Chapters: 24 + 29. Appendices: 7 + 9.
  • Companion code: 177 projects for the agents book; 30 runnable samples plus the SmartDocs solution for the RAG book. I didn't add those into one total, because the RAG files don't give a project count for the SmartDocs solution.

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

This field is about 2,700 characters, so I've summarised it rather than pasting it here; the full text is in 2-about-the-bundle.txt. It runs:

  • An opening paragraph for each book, taken from its own second-edition copy.
  • The "two halves of the same problem" argument from your September copy.
  • An "In the bundle" list:
    • 1,526 pages across 53 chapters, plus 16 appendices;
    • .NET 10, C# 14 and Microsoft Agent Framework 1.28 in both books;
    • the two Contoso systems you build;
    • the two companion repositories;
    • tests that run without an API key;
    • the Python-to-.NET Rosetta, plus the Semantic Kernel and AutoGen migration maps.
  • A paragraph saying both books state what was tested and what wasn't.
  • Who the books are for, ending with "This is the .NET path, end to end."

Books

About the Books

Building AI Agents with C# and .NET 10

Building AI Agents with C# and .NET 10

A Developer’s First Guide to the Microsoft Agent Framework

A working agent takes about twenty lines of C#. The trouble starts once it’s attached to something that matters. A reimbursement is paid twice because a timeout made the orchestration retry an approved call. An answer cites last year’s travel policy. A user in one tenant reads another tenant’s conversation by sending its id. None of those failures lives in the model. They live in the code around it, which is the code you own.

Building AI Agents with C# and .NET 10, Second Edition is about that code. The first edition showed you how to make an agent work. This one shows you how to tell whether it keeps working: when the model is wrong, when the network drops between an approval and a payment, when the process dies while a claim waits for review. Twenty-four chapters in six parts, on Microsoft Agent Framework 1.28, .NET 10 LTS and C# 14.

You will learn how to:

•         Decide whether a task needs an agent at all, and when a plain function does the job better

•         Count tokens for real, pin the SDK and the packages, and keep every secret out of the repository

•         Build your first ChatClientAgent together with its first test, against a fake model that needs no key

•         Get typed C# records back from the model, and check that the record describes something possible

•         Give an agent conversations that survive a restart, belong to one person and can be deleted

•         Add tools with real brakes on the loop, and turn a model’s proposal into an action that application policy authorizes and commits once

•         Serve tools over the Model Context Protocol across trust boundaries, without letting a visible tool become a callable one

•         Ground answers in documents the user is allowed to see, keep a replaced policy out of today’s answer, and read receipts into typed fields

•         Choose a multi-agent topology by measurement, draw a review as a typed workflow graph, and resume a claim in another process after a crash

•         Host agents behind validated identities with tenant isolation, and build streaming interfaces where an approval is a decision about exact arguments

•         Trace a wrong answer to the step that produced it, enforce security policy where the effect happens, and evaluate with the uncertainty printed next to the score

•         Price the work, find the load at which the service stops keeping its promises, qualify a release candidate, and keep it working while models and data change

 

Along the way you build Contoso’s expense assistant through eight versions, from a first agent with a fake model to a release candidate with a qualification dossier that states what was tested and what wasn’t. Payments are simulated: no sample moves real money.

What makes this book different is proof. Every printed output was copied from a captured run. Most samples have a --self-test mode that runs against a scripted chat client, needs no model and no key, prints RESULT n/n and fails when a check fails, so you can check a chapter’s claims on your own machine. The samples that call a model were run against a local Ollama. The Azure OpenAI, OpenAI, Anthropic and Microsoft Foundry paths compile and pass their offline tests, but the book says plainly that they weren’t run against those services. Every chapter ends with three exercises (Basic, Intermediate, Challenge) with acceptance criteria, and the companion repository holds 177 projects: 122 chapter samples, 47 exercise solutions and the 8 Contoso versions.

Written for .NET developers who have shipped an ASP.NET Core service or a console tool and now have to put an agent into a system that already has users. No machine-learning background required. Read the first edition? The Introduction gives you a path through what changed, and Appendix E maps the old project names to the new ones. Coming from Semantic Kernel or AutoGen? Appendix C is your map, with the full migration guides in the repository.

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

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, Second Edition, is about the gap between a RAG demo that works and a system you can trust. The demo answers the easy question. The system has to say when the documents can't answer, keep two users with different permissions apart, and survive an index update without losing the last version that worked.

It is written for .NET developers with a few years of C# behind them who want to ship something useful over their company's documents. You don't need to know the Microsoft Agent Framework, vector databases or graph databases before you start. The only prerequisite is C#.

Across twenty-nine chapters in seven parts and 825 pages, you build Contoso SmartDocs, a knowledge assistant in front of six document silos, from a small console program in Chapter 1 to a composed, validated application in Chapter 29. The code targets .NET 10 and C# 14 with Microsoft Agent Framework 1.28.0, Microsoft.Extensions.AI 10.11.1, the ModelContextProtocol SDK 2.4.0 and Qdrant.Client 1.20.0.

What you'll build, part by part:

•         Foundations. When RAG is the right tool, a reproducible .NET environment, and a first measured baseline on a pinned 40-case gold set, taken before you tune anything.

•         The RAG pipeline. Embeddings, document contracts and reliable ingestion, chunking with Contextual Retrieval, multimodal evidence, vector indexes, indexing representations, hybrid retrieval, reranking, and context assembly with citations and streaming.

•         Access and query intelligence. Authorization first, with one disclosure guard applied at search, the reranker, caches, citations, tools, agents and sessions. Then metadata filters, query construction, routing and conversational rewriting.

•         Graph and hybrid storage. Graph data with entity resolution, and single-store hybrid on PostgreSQL, Qdrant and Azure AI Search (plus a SQL Server recipe), held to one set of conformance cases, with a plain account of what those cases do and don't prove.

•         RAG design patterns. Measured enhancements such as HyDE, RAG-Fusion and CRAG, structural and vectorless retrieval, GraphRAG with deferred graph retrieval, MCP as a secure contract, and bounded agents with workflows and memory.

•         Production concerns. Evaluation and release decisions, with a regression gate kept apart from an absolute quality floor and a dated run against real local models; latency and cost, freshness and model migration, security testing, governance, and five reproducible failure labs that break things on purpose.

•         The capstone. Named compositions validated at startup, a supported storage topology, index generations for cutover, and a release dossier with known limits.

Every SmartDocs listing is copied from a file in the companion repository and names that file on its first line. When a chapter prints output, the code produced it. Numbers that could not be measured or sourced are not in the book, and facts that change with releases carry a date.

"Production-grade" here means a reference architecture with production disciplines, not a turnkey deployment. The book keeps what the code guarantees and tests apart from the exercises and the known gaps. The local backends (Qdrant, PostgreSQL with pgvector, Neo4j, Ollama and the ONNX reranker) passed a dated live run; the Azure deployment shape compiles and is tested offline but has never been deployed, and the book says so. The repository has one page that lists each level of evidence.

Nine appendices round it out: worked solutions for the Practice exercises; a quick reference of the design patterns; a backend comparison workbook you fill in with your own measurements; an embedding experiment protocol; a Python-to-.NET Rosetta for readers arriving from LangChain, LlamaIndex or RAGAS; a guide to the companion repository; a debugging checklist that runs from symptom to cause to fix; a catalog of every prompt template the chapters use; and the math behind RAG. A References and Further Reading section and an index close the book.

The free sample is all of Part I, Foundations: Chapters 1 to 3, ending on the measured baseline.

The companion code lives at https://github.com/RachidD68/production-grade-rag-with-csharp-and-dotnet, on the main and edition-2 branches (tag v2.0.0): thirty runnable sample projects beside the SmartDocs solution. dotnet test from the repository root needs no service and no API key; the tests that need a live service or a second build skip themselves and name the RUN_* variable that turns them on, and the real-model reranker test stays skipped until you add the model files.

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.)

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