Building AI features in .NET: LLM basics, Azure OpenAI with Microsoft.Extensions.AI and Semantic Kernel, embeddings, vector search, RAG, function calling, evaluation, prompt injection and data-leakage prevention.
-
How do you keep the cost of an LLM feature under control in production? Cover model choice, prompt and history trimming, caching, output caps and budgets per user or tenant.
Beginner
Theory
.NET and AI
-
Why does an LLM sometimes give confident but wrong answers (hallucination), and what can a .NET developer do to reduce it?
Beginner
Theory
.NET and AI
-
How do you measure retrieval quality for a search or RAG feature? Explain hit rate, recall@k, MRR and nDCG, and how you build the labelled test set.
Intermediate
Theory
.NET and AI
-
When would you use hybrid search with a reranker instead of pure vector search, and how does reciprocal rank fusion combine the results?
Intermediate
Theory
.NET and AI
-
When should you use structured output (a JSON schema response) instead of tool calling, and how do you validate the result in .NET?
Mid-Level
Coding
.NET and AI
-
What is the difference between an AI agent and a workflow that calls an LLM at fixed steps, and how do you decide which one a feature needs?
Mid-Level
Theory
.NET and AI
-
You're a .NET developer about to call an LLM for the first time. What are tokens, the context window, temperature and a chat completion, and how do they drive cost and latency?
LLM basics for a .NET developer: tokens and tokenisation, the context window, temperature and sampling, the chat completions message model (system, user, assistant), statelessness, and how tokens drive cost and latency.
Beginner
Theory
.NET and AI
Β· π 2 follow-ups
-
Show me how you'd call Azure OpenAI from an ASP.NET Core API using Microsoft.Extensions.AI. How do you register IChatClient in DI, authenticate without keys, stream the reply to the browser, and handle timeouts and throttling?
Calling Azure OpenAI from ASP.NET Core with Microsoft.Extensions.AI: AzureOpenAIClient with DefaultAzureCredential and managed identity, AddChatClient with the ChatClientBuilder pipeline, streaming with GetStreamingResponseAsync and IAsyncEnumerable or server-sent events, cancellation, and 429 handling.
Junior
Coding
.NET and AI
Β· π 2 follow-ups
-
What is an embedding, and how does vector search work? Explain similarity measures, why and how you chunk documents, and how you'd choose between Azure AI Search, SQL Server 2025's vector type, Cosmos DB and pgvector for a .NET app.
Embeddings and vector search: what an embedding vector represents, cosine similarity and dot product, exact versus approximate (HNSW) nearest-neighbour search, chunking strategies, hybrid search, IEmbeddingGenerator and Microsoft.Extensions.VectorData, and choosing a vector store.
Intermediate
Theory
.NET and AI
Β· π 2 follow-ups
-
Walk me through building a retrieval-augmented generation (RAG) pipeline in .NET. How do you ingest, chunk, embed and store documents, retrieve the right chunks for a question, ground the prompt, cite sources, and know that it works?
End-to-end RAG in .NET: ingestion and chunking, embedding with IEmbeddingGenerator, storing with Microsoft.Extensions.VectorData, hybrid retrieval with permission filters, grounding prompts with numbered sources and citations, refusal when nothing relevant is found, and evaluation, cost and latency.
Mid-Level
Coding
.NET and AI
Β· π 2 follow-ups Β· π 1 real-world
-
How does function (tool) calling work with an LLM in .NET? Show how you describe C# methods as tools with Microsoft.Extensions.AI, let the model call them, validate the arguments, and stop it doing something it shouldn't.
Function and tool calling in .NET: the model returns tool-call requests with JSON arguments, the app executes them; AIFunctionFactory, ChatOptions.Tools and UseFunctionInvocation; schemas from method signatures and descriptions; argument validation, authorisation in the tool, iteration limits, approval for side effects, and structured output.
Mid-Level
Coding
.NET and AI
Β· π 2 follow-ups Β· π 1 real-world
-
In 2026, when would you use Microsoft.Extensions.AI, Semantic Kernel or the Microsoft Agent Framework in a .NET app? Explain what each one is for, how they relate, and how you'd choose for a new project or an existing Semantic Kernel codebase.
The .NET AI stack in 2026: Microsoft.Extensions.AI as the abstraction layer (IChatClient, IEmbeddingGenerator, middleware), Microsoft.Extensions.VectorData for vector stores, Semantic Kernel's plugins and current maintenance status, and the Microsoft Agent Framework (GA as 1.0 in April 2026) for agents and workflows, with guidance for new and existing projects.
Mid-Level
Theory
.NET and AI
Β· π 2 follow-ups Β· π 1 real-world
-
What is prompt injection, and how do you defend a .NET AI feature against it? Explain direct and indirect injection through retrieved documents, emails or tool results, and the layered controls you'd put in place given that no prompt fully prevents it.
Prompt injection in .NET AI features: direct (user) and indirect (documents, web pages, emails, tool output) injection, why it cannot be fully prevented, and layered defences: least-privilege tools, authorisation in code, delimiting untrusted content, Azure AI Content Safety Prompt Shields, output handling, human confirmation, and red-team evaluation.
Senior
Security
.NET and AI
Β· π 2 follow-ups Β· π 1 real-world
-
How do you stop an AI feature leaking data? Talk me through personal information in prompts, tenant and permission isolation in RAG, logging prompts and responses safely, where the model provider processes and keeps data, and what the Privacy Act requires.
Preventing data leakage in .NET AI features: data minimisation and redaction before prompts, tenant and ACL isolation in vector indexes, safe prompt and response logging with Microsoft.Extensions.Compliance.Redaction, provider data handling (Azure OpenAI residency, abuse-monitoring retention), output filtering, and Privacy Act 1988 obligations (APP 6, 8, 11, NDB, automated-decision transparency).
Senior
Security
.NET and AI
Β· π 2 follow-ups Β· π 1 real-world
-
How do you know an AI feature actually works, and keeps working? Explain how you build an evaluation set, which metrics you use (groundedness, relevance, retrieval quality, safety), LLM-as-judge and its limits, and how you regression-test prompt and model changes in CI.
Evaluating AI features in .NET: building a golden evaluation set, retrieval metrics versus answer metrics, groundedness, relevance and completeness with Microsoft.Extensions.AI.Evaluation, LLM-as-judge calibration and bias, deterministic checks, safety evaluation, CI regression gates for prompt and model changes, and production feedback loops.
Senior
Theory
.NET and AI
Β· π 2 follow-ups Β· π 1 real-world
-
Your RAG assistant is live, and users report confident answers that are wrong, sometimes quoting the right document but the wrong clause. How do you investigate whether the problem is retrieval, chunking or the prompt, and how do you fix it?
Production troubleshooting of a RAG assistant giving confident wrong answers: tracing a bad answer through retrieval, chunks and prompt, separating retrieval failures from generation failures, fixing chunking (split tables and clauses), hybrid search, reranking, relevance thresholds, grounding and citation rules, and preventing recurrence with evaluation and monitoring.
Senior
RealWorldScenario
.NET and AI
Β· π 3 follow-ups Β· π 1 real-world