Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 38 of 39
❮Prev Next❯

Connect Retrieval Pipelines to Agents and Workflows

Module 5: Information Extraction ⏱ 13 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    Agents don't call an index directly. You create knowledge sources (such as a search index), group them in a knowledge base with a retrieval reasoning effort (minimal, low or medium), and give the agent the knowledge base as a tool through its MCP endpoint. The project's managed identity needs the Search Index Data Reader role on the search service, or the call fails with 403. Instructions tell the agent to cite sources and to say "I don't know" when nothing comes back. Workflows and apps call the same knowledge base through the retrieve API.

    Simulate it » No Azure account needed

    Exam objective: 5.1.5 Connect retrieval pipelines directly to workflows and agent tools. (Skills measured as of April 16, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Create a knowledge base and connect it to an agent as a tool Create a knowledge base and connect it to an agent as a tool.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    In the Foundry portal open <strong>Build ➜ Knowledge</strong> and create a knowledge base.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. In the Foundry portal open Build ➜ Knowledge and create a knowledge base.
    2. Name it, choose the search service, add the index as a knowledge source, and pick the retrieval reasoning effort. Minimal skips model planning; low and medium use a model to plan subqueries.
    3. The agent reaches the knowledge base through its MCP endpoint, using a project connection that authenticates as the project's managed identity.
    4. On the search service, give the project's managed identity the Search Index Data Reader role. This is the step people forget.
    5. Add the tool to the agent, allow only the retrieve tool, and write instructions that say what to do when nothing is found.
    6. Test it. The answer carries a citation, and Tracing shows the knowledge base call with its subqueries.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    The agent answers policy questions from memory, makes up details and cannot read the search index it was given.

    😊 THE SOLUTION

    Give it a knowledge base as a tool, grant the project identity the Search Index Data Reader role and tell it to cite or say it does not know.

    • Invented policy details✓ Ground the agent on a knowledge base and require citations
    • 403 from the search service✓ Search Index Data Reader for the project managed identity
    • Multi-part questions answered badly✓ Low or medium retrieval reasoning effort
    🛠️ Solved with: Knowledge base, MCP tool and agent instructions

    Start with a question

    Your HR agent confidently invents a parental leave rule. How do you make it answer from the real policies, and say so when it can't?

    Think of a new employee at a help desk. If you give them no manual, they guess. If you give them a manual and tell them “answer from the manual and point to the page”, they stop guessing. If the answer isn’t in the manual, they say “let me check”.

    A knowledge base is the manual, a knowledge source is one book in it, and the MCP tool is the agent’s way to open it. The managed identity is the staff badge that lets the agent into the library, and the instructions are the rule: cite the page, or say you don’t know.

    Explain it like I’m 10

    The technical explanation

    You’ve built an index. Now the agent has to use it, safely and with citations.

    The pieces

    PieceJob
    Knowledge sourcePoints at content: a search index on your service, Blob Storage, SharePoint, OneLake, or the web.
    Knowledge baseLists knowledge sources, sets the retrieval reasoning effort and the output mode, and exposes retrieve and MCP endpoints.
    Agentic retrievalPlans subqueries, runs them in parallel (keyword, vector or hybrid), reranks each with the semantic ranker and merges the result.
    AgentA Foundry agent with the knowledge base as a tool and instructions about how to use it.

    Indexed sources need a semantic configuration on the index, because every subquery is reranked.

    Retrieval reasoning effort

    EffortWhat happensNeeds a model?
    minimalOne query goes to the candidate sources as it is.No (unless you want answer synthesis)
    lowA model plans subqueries and picks sources.Yes
    mediumMore planning and iteration than low.Yes

    Set it explicitly instead of assuming a default. A question such as “Can I expense a taxi from the airport, and how long do I have to claim it?” is really two questions. At minimal effort it’s one blended query; at low effort it becomes two focused ones that run in parallel.

    The output mode is either extractive data (raw passages with references, which your agent or app reasons over) or answer synthesis (the knowledge base writes a cited answer, which needs a model).

    Creating them (REST, GA contract 2026-10-01)

    PUT /knowledgesources/ks-policies?api-version=2026-10-01
    { "name": "ks-policies", "kind": "searchIndex",
      "searchIndexParameters": { "searchIndexName": "policies-idx" } }
    
    PUT /knowledgebases/kb-policies?api-version=2026-10-01
    { "name": "kb-policies",
      "knowledgeSources": [ { "name": "ks-policies" } ],
      "retrievalReasoningEffort": { "kind": "low" },
      "outputMode": "extractiveData",
      "models": [ { "kind": "azureOpenAI", "azureOpenAIParameters": {
          "resourceUri": "https://ai-agt-kb01.openai.azure.com",
          "deploymentId": "gpt-4.1-mini", "modelName": "gpt-4.1-mini" } } ] }

    Some agentic retrieval features are still in preview, and which ones you get depends on the Search REST API version you call. As of 25 November 2026, 2026-10-01 is the GA contract for minimal, low and medium effort, citations and answer synthesis, and a preview version adds newer items. Check the current migration page when you build.

    Connecting the agent

    1. Create a project connection to the knowledge base’s MCP endpoint (.../knowledgebases/<name>/mcp), using the project managed identity and the search audience.
    2. Add the tool to the agent with allowed_tools limited to the retrieve tool, and decide on require_approval (reading a policy index is low risk).
    3. Grant the role. On the search service, assign the project’s managed identity Search Index Data Reader. Read-only is all an agent needs.
    4. Write the instructions. Say to answer from the retrieved passages, cite the sources, and reply that it doesn’t know when nothing relevant comes back.
    tool = MCPTool(server_label="policies", server_url=mcp_endpoint,
                   require_approval="never", allowed_tools=["knowledge_base_retrieve"],
                   project_connection_id="kb-policies-mcp")
    agent = project.agents.create_version(agent_name="policy-agent",
        definition=PromptAgentDefinition(model="gpt-4.1-mini", tools=[tool],
            instructions="Use the knowledge base tool. If it has no answer, say you don't know. Cite sources."))

    Without the role you get a 403 on the first tool call, which is the classic mistake. Network settings matter too: a private connection between the agent and the search service doesn’t automatically protect the search service’s own connections to its data sources and models.

    Workflows and apps

    Anything that can make an HTTPS call can use the same knowledge base: a Logic Apps or Power Automate step, an Azure Function, or a Microsoft Agent Framework app. They call the retrieve endpoint (or SDK) with the conversation, then pass the returned passages to a model or use them directly. One knowledge base can serve many agents.

    Other ways to ground an agent

    OptionUse it when
    Knowledge base (Foundry IQ)Curated company content shared by many agents, with planning and citations
    Azure AI Search tool on an indexOne index and a simple, direct query
    File searchFiles a user uploads in a conversation
    Function toolLive data from a system of record
    1. 1 Ask

      The agent calls the knowledge base tool with the question.

    2. 2 Plan

      At low or medium effort a model splits it into subqueries.

    3. 3 Search

      Subqueries run in parallel over the knowledge sources, each reranked.

    4. 4 Merge

      Passages and references come back to the agent.

    5. 5 Answer

      The agent answers with citations, or says it does not know.

    One question through a knowledge base
    Architect level Permissions and cost

    Sources such as SharePoint and some others can carry access control lists, and the knowledge base can run queries under the caller’s Microsoft Entra identity so users only get content they’re allowed to see. For your own indexes, store group IDs on each chunk and apply a filter that matches the signed-in user.

    Agentic retrieval is billed in more than one place: the semantic ranker reranks up to 50 chunks per subquery, and low and medium effort add model tokens for planning and, if you use it, answer synthesis. Lower the effort, reduce the number of sources, or answer simple questions with minimal effort to keep cost down. Review the activity log the retrieve call can return, which shows each subquery and how many results it produced.

    Real-world business scenario

    Human resources

    Contoso HR (fictional)

    The problem
    The HR chatbot answered travel and leave questions from memory. Employees were told wrong claim deadlines, and an audit found no way to see where an answer came from.
    What they used
    A knowledge base over the policies index at low retrieval effort, connected to the HR agent as an MCP tool with the project's managed identity and Search Index Data Reader. Instructions require citations and an I don't know reply.
    Why that choice
    Multi-part questions are split and answered from the right documents, there are no keys to manage, and every answer carries the file it came from.
    The result
    Wrong-deadline tickets fell by almost two thirds, and auditors can follow each answer back to a policy page.

    When to use it and when not to

    ✓ Use it when…

    • Several agents or apps should share one curated, cited source of company knowledge.
    • Users ask multi-part or context-dependent questions that one query can't answer.
    • You need keyless access and permission-aware answers.

    ✕ Think twice when…

    • The question needs live data from a system of record. Use a function tool.
    • A user uploads a file for one chat. File search is lighter.
    • Latency and cost are tight and questions are simple. Use minimal effort or a direct index query.

    ↔ Alternatives to consider

    • Azure AI Search tool for a direct query on one index.
    • File search for per-conversation files.
    • Retrieve API in a workflow when no agent is involved.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AI-103 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    A Foundry agent calls a knowledge base through its MCP tool by using the project's managed identity. Every call returns 403. What should you do?

    Question 2

    Question 2 of 5

    Users ask two-part questions such as "Can I expense a taxi, and how long do I have to claim it?". You want the knowledge base to split them into subqueries. What should you configure?

    Question 3

    Question 3 of 5

    An agent must say that it does not know when the knowledge base returns nothing relevant, and cite sources otherwise. Where should you put these requirements?

    Question 4

    Question 4 of 5

    Several agents must share one curated source of company policies with planned subqueries and citations. Which design fits?

    Question 5

    Question 5 of 5 · Select 2

    Which two statements about connecting a workflow or application to a knowledge base are correct?

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner Why give an agent a knowledge base instead of letting the model answer on its own?

    Model answer

    A model only knows what it was trained on and what's in the prompt. A knowledge base lets the agent look up your current company content and answer from it, with citations you can check.

    Intermediate What is the difference between minimal, low and medium retrieval reasoning effort?

    Model answer

    Minimal skips model planning and sends the question to the sources as it is, so it's fastest and cheapest. Low and medium use a chat model to break the question into subqueries and choose sources, with medium doing more of that work. They cost more tokens and add latency, but handle multi-part questions better.

    Interviewer follows up

    Which setting needs a model deployment?

    You

    Low and medium, for planning. Answer synthesis also needs a model, whatever the effort.

    Experienced developer The agent's knowledge base call returns 403. What do you check?

    Model answer

    The identity the tool authenticates as. With a project connection it's the project's managed identity, so I'd confirm it has Search Index Data Reader on the search service, that the connection audience is the search endpoint, and that network rules allow the call.

    Scenario The agent invents a refund rule that isn't in your policies. How do you stop it?

    Model answer

    Ground it on the knowledge base, write instructions that say to answer only from retrieved passages, cite them and admit when nothing relevant came back, and evaluate groundedness on a test set. If retrieval returns nothing useful, fix the index first, not the prompt.

    Architecture & design How do you make sure users only see documents they're allowed to see?

    Model answer

    Use sources that carry access control information and have the knowledge base run queries under the caller's Microsoft Entra identity where supported, so permissions are enforced at query time. For custom indexes I'd store security groups on each chunk and filter on them.

    Quick revision

    Key points

    • Agents call a knowledge base. The knowledge base holds knowledge sources and the retrieval settings.
    • Minimal effort has no model planning. Low and medium use a chat model to plan subqueries.
    • The agent reaches the knowledge base as an MCP tool, authenticated through a project connection.
    • The project's managed identity needs Search Index Data Reader on the search service.
    • Instructions must require citations and an honest "I don't know".
    • Workflows and apps use the retrieve REST API or SDK on the same knowledge base.

    Important terminology

    Knowledge source
    A connection to content for retrieval, such as a search index, Blob Storage, SharePoint, OneLake or the web.
    Knowledge base
    The top-level object that lists knowledge sources and controls retrieval, including the reasoning effort and the output mode.
    Agentic retrieval
    A multi-query pipeline that plans subqueries, runs them in parallel, reranks with the semantic ranker and merges the results.
    Retrieval reasoning effort
    A knowledge base setting (minimal, low or medium) that decides how much model-based query planning happens.
    MCP tool
    A tool an agent calls through the Model Context Protocol. A knowledge base exposes one at its MCP endpoint.
    Project connection
    A Foundry project setting that stores how the agent authenticates to a tool, such as the project's managed identity.
    Search Index Data Reader
    The role that allows read-only queries on a search service's indexes.

    Common mistakes

    • Granting a broad role such as Owner or Contributor when Search Index Data Reader is enough.
    • Expecting multi-part questions to be split at minimal effort.
    • Letting the agent answer from memory when retrieval returns nothing.

    Exam tips

    • "Agent calls search with no keys" = project managed identity plus Search Index Data Reader.
    • "Break a multi-part question into subqueries" = low or medium reasoning effort.
    • "Expose retrieval to an agent as a tool" = the knowledge base MCP endpoint.

    Five quick revision questions

    1. 1.Which object do agents call for retrieval?Show

      A knowledge base.

    2. 2.Which effort level skips model planning?Show

      Minimal.

    3. 3.Which role lets the project identity read the index?Show

      Search Index Data Reader.

    4. 4.How does an agent reach the knowledge base as a tool?Show

      Through its MCP endpoint.

    5. 5.What should the agent say when nothing relevant is retrieved?Show

      That it doesn't know.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Extract Documents with Content Understanding

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.