Connect Retrieval Pipelines to Agents and Workflows
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 neededExam 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.
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
- In the Foundry portal open Build ➜ Knowledge and create a knowledge base.
- 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.
- The agent reaches the knowledge base through its MCP endpoint, using a project connection that authenticates as the project's managed identity.
- On the search service, give the project's managed identity the Search Index Data Reader role. This is the step people forget.
- Add the tool to the agent, allow only the retrieve tool, and write instructions that say what to do when nothing is found.
- 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.
🖱️ Drag to rotate · scroll or pinch to zoom
Connect retrieval to an agent
A Foundry agent gets a knowledge base as a tool (an MCP endpoint). The project’s managed identity needs the Search Index Data Reader role. A retrieval reasoning effort of minimal, low or medium decides whether a model plans subqueries. Answers should come back with citations.
🤔 What happens if…
Read this tour as text
- Ingest and index content. An indexer reads files from a data source, runs a skillset (OCR, Text Split, an embedding model) and writes one search document per chunk into the index. Scanned images only become searchable when the OCR skill gets the images (imageAction: generateNormalizedImages).
- Keyword, vector, hybrid and semantic. Keyword search (BM25) matches words. Vector search compares embeddings, so it matches meaning. Hybrid runs both in parallel and merges them with Reciprocal Rank Fusion. The semantic ranker then re-reads the top 50 results with a language model and adds captions.
- Enrich with skills. A skillset is a chain of skills that adds fields to each document: built-in skills such as OCR, PII Detection and Key Phrase Extraction, a Web API custom skill for your own code, and the Content Understanding skill for layout-aware chunking. Outputs reach the index through output field mappings or index projections.
- Connect retrieval to an agent. A Foundry agent gets a knowledge base as a tool (an MCP endpoint). The project’s managed identity needs the Search Index Data Reader role. A retrieval reasoning effort of minimal, low or medium decides whether a model plans subqueries. Answers should come back with citations.
- Content Understanding analyzers. An analyzer turns a document into Markdown (layout, tables, figures) and into fields you define. Each field uses a method: extract (text on the page), classify (a fixed list) or generate (the model writes it). Fields come with a confidence score and a source location.
The policy index is ready. Wrap it in a knowledge source and a knowledge base, compare minimal and low retrieval effort on a two-part question, then give a Foundry agent the knowledge base as a tool. The first call fails with a 403: find out why.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 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
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
| Piece | Job |
|---|---|
| Knowledge source | Points at content: a search index on your service, Blob Storage, SharePoint, OneLake, or the web. |
| Knowledge base | Lists knowledge sources, sets the retrieval reasoning effort and the output mode, and exposes retrieve and MCP endpoints. |
| Agentic retrieval | Plans subqueries, runs them in parallel (keyword, vector or hybrid), reranks each with the semantic ranker and merges the result. |
| Agent | A 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
| Effort | What happens | Needs a model? |
|---|---|---|
| minimal | One query goes to the candidate sources as it is. | No (unless you want answer synthesis) |
| low | A model plans subqueries and picks sources. | Yes |
| medium | More 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
- Create a project connection to the knowledge base’s MCP endpoint (
.../knowledgebases/<name>/mcp), using the project managed identity and the search audience. - Add the tool to the agent with
allowed_toolslimited to the retrieve tool, and decide onrequire_approval(reading a policy index is low risk). - Grant the role. On the search service, assign the project’s managed identity Search Index Data Reader. Read-only is all an agent needs.
- 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
| Option | Use it when |
|---|---|
| Knowledge base (Foundry IQ) | Curated company content shared by many agents, with planning and citations |
| Azure AI Search tool on an index | One index and a simple, direct query |
| File search | Files a user uploads in a conversation |
| Function tool | Live data from a system of record |
-
1 Ask
The agent calls the knowledge base tool with the question.
-
2 Plan
At low or medium effort a model splits it into subqueries.
-
3 Search
Subqueries run in parallel over the knowledge sources, each reranked.
-
4 Merge
Passages and references come back to the agent.
-
5 Answer
The agent answers with citations, or says it does not know.
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
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.
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.
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.Which object do agents call for retrieval?Show
A knowledge base.
-
2.Which effort level skips model planning?Show
Minimal.
-
3.Which role lets the project identity read the index?Show
Search Index Data Reader.
-
4.How does an agent reach the knowledge base as a tool?Show
Through its MCP endpoint.
-
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
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.