Skip to main content
TechExplainedTechExplained
|
How-toLevel: Intermediate

How to build a RAG solution

Step by step from a mountain of documents to reliable RAG with Foundry and Azure AI Search, with the decision that really matters at each step.

TechExplained 2 min readPublished: 8 June 2026Last updated: 8 June 2026
#rag#how-to#azure ai search
Enterprise engineer designing a Retrieval-Augmented Generation solution with Azure AI Search and Microsoft Foundry.
All how-tos
  1. 01

    Define what a good answer is

    Collect fifty to two hundred representative questions with the answers an expert would give, including the expected sources. This is your evaluation set, your regression test for AI, which you run on every change. Without measured quality, every improvement is guesswork.

    Decision
    what does the system do when in doubt, guess or refuse? In almost every enterprise context, refusing is the right answer.
  2. 02

    Get your sources in order

    Inventory the documents: owner, currency, duplicate versions. Archive what is outdated before you index.

    Decision
    which sources are authoritative? RAG on conflicting sources gives conflicting answers, no model solves that.
  3. 03

    Chunking and indexing

    Chunk on document structure (headings, articles, clauses) with overlap. Index in Azure AI Search with both vectors and keywords, and turn on semantic ranking. Include metadata: source, version, publication date, audience.

    Decision
    chunk size. Too small loses context, too large dilutes relevance. Start around a few hundred tokens and let your evaluation set decide.
  4. 04

    Tune retrieval

    Test hybrid search against your evaluation set before a model is involved: is the right piece of text in the top five results? If not, this is your problem, not the generation.

    Decision
    retrieval threshold. Below which score do you refuse to answer?
  5. 05

    Generation with grounding

    Choose a model in Foundry and write a system prompt with three hard rules: answer only from the supplied passages, always cite the source, and say so explicitly when the information is missing.

    Decision
    model size. Start small; upgrade only when your evaluation set shows it is needed. The difference is more often in retrieval than in the model.
  6. 06

    Evaluate and log

    Run your evaluation set on every change (Foundry evaluations helps with this). Retrieval, groundedness and relevance are built-in evaluators; refusal behavior is not, so you build that as a custom evaluator, which is still preview. In production, log every interaction with retrieved chunks and scores.

  7. 07

    Manage as a product

    Documents change, so indexes do too. Arrange reindexing on publication, monitor unanswered questions as a backlog and repeat the evaluation monthly. RAG is not a project with an end date; it is a product with a data chain.

The process at a glance

Click a step for its key decision

Decision

Define what a good answer is

what does the system do when in doubt, guess or refuse? In almost every enterprise context, refusing is the right answer.

How to build a RAG solution | TechExplained