Bluemesh
Language: EnglishEN
Menu

Home / Selected work

A document assistant designed so each person sees only what they are allowed to read

A reference build for a fictional company with sample data, built by Bluemesh on Azure in Canada in November 2026. Documents, permissions, search and the AI agent are designed as one system, published to Microsoft Teams, tested and written in Terraform.

At a glance

Service
AI Solutions Architecture
Cloud
Azure, Canada Central and Canada East
When
November 2026
Type
Reference build with sample data

Results

returned when a query has no sign-in token
0 documents
multi-document questions with agentic retrieval, compared with 14 for classic search
17 of 20
checks passed in a Foundry evaluation run
19 of 21
Talk to Bluemesh

The story

The situation

A common weak spot in document assistants built on retrieval-augmented generation (RAG): they search everything with one service account. The answer can then quote a document the person asking was never allowed to open.

Why it usually goes wrong

Permissions, search and the AI agent are often designed separately. This build treats them as one system.

What was built

  • Permissions on the data. Documents in Azure Data Lake Storage Gen2, one folder per audience, each with an access control list (ACL) for a Microsoft Entra group. Default ACLs make new files inherit their folder's permissions.
  • Passages that keep their context. Each file is split at its headings before upload, and each passage carries its document title.
  • Permissions in the index. An Azure AI Search indexer stores each passage's group IDs as permission metadata and creates vectors with Foundry embeddings.
  • Agentic retrieval. A knowledge base with query planning turns a question into focused subqueries, runs them in parallel and reranks the results.
  • The user's sign-in token passed to search. A Foundry agent calls the knowledge base as a Model Context Protocol (MCP) tool and is designed to pass the signed-in user's token, so search filters by that user's groups.
  • Where people already work. Published to Microsoft Teams and Microsoft 365 Copilot through Azure Bot Service.
  • A gateway for applications. Azure API Management sits in front of the models for applications. It checks the user's Entra sign-in token, limits how many model tokens each user can use, records token use, and reaches the models with a managed identity. No API keys are stored anywhere.
  • Infrastructure as code. Everything is written in Terraform, including the search objects.

The trade-off

The agent's own model calls do not pass through API Management: routing them through it needed a higher tier. The lower-cost tier was chosen for this build, and the trade-off is written down. AI Search runs in Canada Central and Foundry in Canada East, where model capacity was available, with the models on Regional Standard deployments. Both stay in Canada.

How it was tested

  • It fails closed. A query with no sign-in token returns 0 documents.
  • The right groups. Spot checks in each audience folder returned the right groups on each kind of document.
  • Better retrieval where it matters. Agentic retrieval did better than classic search on the test set, most clearly on questions that span several documents: 17 of 20, compared with 14. Query planning costs about 950 model tokens per question.
  • One regression, reported. One question got worse: the query planner lost track of a question that needed two lookups in a row.
  • An evaluation run. A quick Foundry evaluation passed 19 of 21 checks, and every answer was supported by the source documents (groundedness 100%).
  • The gateway. A request with no sign-in token is refused (401), a valid token is accepted (200), and a user over their token budget is refused (429).

Known limits

Counting questions fail, such as "how many contracts end this quarter?": retrieval returns the most relevant passages, not every record. That needs structured data or a counting tool. Per-user filtering is designed and tested at the index. The next step is a leak test through the agent: sign in as a restricted user and check that the agent never returns a document that user cannot open.

How the parts fit

The parts used in this project, in the order a request moves through them.

  1. User in Teamssigns in with Entra ID
  2. Azure Bot Servicethe Teams channel
  3. Foundry agentcalls one tool
  4. Knowledge base (MCP)runs with the user's sign-in token
  5. AI Search indexgroup IDs on every passage, fails closed
  6. Data Lake Storagefolders with group ACLs
  7. Modelmanaged identity; API Management for applications

Technology used in this project

  • Microsoft Foundry
  • Azure AI Search agentic retrieval
  • Model Context Protocol (MCP)
  • Microsoft Entra ID groups and ACLs
  • Azure Data Lake Storage Gen2
  • Azure API Management
  • Azure Bot Service
  • Microsoft Teams
  • Microsoft 365 Copilot
  • Managed identities
  • Terraform

How Bluemesh builds it today

A reference architecture for a new project, based on current Azure and AWS guidance. It describes what Bluemesh would build now, not what was built in the project above.

Close the gaps

  • Every model call, including the agent's, through the AI gateway.
  • A leak test for every role in the release pipeline, run through the agent, not only at the index.

Protect

  • Private endpoints for Storage, Search and Foundry.
  • Microsoft Purview sensitivity labels enforced at query time (in preview today).
  • Prompt Shields at runtime, and an injection test set as a release gate.

Answer more

  • Structured data or a counting tool for questions that need totals.

Start small

  • One audience folder, one group, twenty real questions, and the leak test before anything else.

Questions

What is security trimming in a RAG assistant?

Filtering search results by the permissions of the person asking, so the model can only use passages that person is allowed to read.

Should we use Microsoft 365 Copilot or build a custom RAG assistant?

Copilot works well on Microsoft 365 content with its own permissions. A custom assistant fits when documents live elsewhere, when you need your own evaluation and gateway controls, or when the assistant must act through specific tools.

Why can't a RAG assistant answer "how many"?

Search returns the most relevant passages, not every record. Totals need a query over structured data.