Enterprise AI applications rarely operate against a single, shared knowledge base. In a typical organization, different customers, departments, or business units may have access to different documents and data.
A support application, for example, may serve hundreds of customers while maintaining strict separation between their knowledge.
This creates a fundamental requirement:
A user should retrieve information only from the knowledge they are authorized to access.
Microsoft Foundry IQ provides a knowledge-layer approach for connecting AI applications with enterprise information sources and grounding agent experiences in organizational data. When this type of capability is combined with multi-tenant applications, identity, metadata, and authorization become just as important as retrieval quality.
This article explains how to design a tenant-aware AI knowledge layer, where tenant boundaries are enforced, how retrieval should work, and what to test before moving the architecture into production.
Introduction
A basic RAG architecture often looks like this:
Documents
|
v
Index
|
v
Retriever
|
v
LLM
|
v
Answer
A multi-tenant enterprise system needs another dimension:
Tenant A Documents ──┐
|
Tenant B Documents ──+──> Knowledge Layer
|
Tenant C Documents ──┘
|
v
Authorized Retrieval
|
v
LLM
The important difference is that retrieval must understand who is asking the question.
For example:
Tenant A
Question:
"What is our refund policy?"
Allowed:
Tenant A policy documents
Denied:
Tenant B policy documents
Internal administration documents
This is not merely a search-ranking problem.
It is an authorization problem.
What Is a Tenant-Aware Knowledge Layer?
A tenant-aware knowledge layer provides a controlled interface between enterprise data and AI applications.
Conceptually:
+-----------------------+
| AI Application |
+-----------+-----------+
|
v
+-----------------------+
| Identity / Tenant |
| Context |
+-----------+-----------+
|
v
+-----------------------+
| Knowledge Layer |
+-----------+-----------+
|
v
+-----------------------+
| Authorized Retrieval |
+-----------+-----------+
|
v
+-----------------------+
| Enterprise Data |
+-----------------------+
The knowledge layer should understand information such as:
Tenant ID
User identity
User roles
Groups
Document ownership
Access permissions
Data classification
Geographic or residency requirements
Document metadata
Microsoft Foundry IQ can be used as part of an enterprise knowledge architecture, but tenant isolation should remain an explicit architectural concern rather than something assumed from the presence of a knowledge service.
Why Multi-Tenant AI Retrieval Is Difficult
Traditional application authorization usually happens after identifying a resource.
For example:
GET /customers/123/invoices
The application checks whether the caller can access customer 123.
RAG introduces a different problem.
The system might search thousands or millions of documents before the final answer is generated.
If unauthorized content enters the retrieval context, the LLM may have access to information that should never have been exposed.
The dangerous flow is:
User
|
v
Search Everything
|
v
Retrieve Unauthorized Document
|
v
LLM
|
v
Unauthorized Answer
The correct flow is:
User
|
v
Resolve Identity + Tenant
|
v
Apply Authorization Boundary
|
v
Retrieve Allowed Content
|
v
LLM
|
v
Grounded Answer
Authorization should therefore happen before or during retrieval, not after generation.
Define the Tenant Context
Start with a clear request context.
public sealed record TenantContext(
string TenantId,
string UserId,
IReadOnlySet<string> Roles,
string Region);
The context should be created from trusted application identity information.
Do not allow the model to specify:
tenantId = "tenant-b"
The tenant identity should come from the authenticated application context.
Associate Documents With Tenants
Every document should have metadata that identifies its ownership and authorization boundary.
For example:
public sealed record KnowledgeDocument(
string Id,
string TenantId,
string Title,
string Content,
string Classification,
string[] AllowedRoles);
A document might contain:
DocumentId: DOC-1001
TenantId: TENANT-A
Classification: Internal
AllowedRoles:
Support
Manager
This metadata becomes part of the retrieval policy.
Tenant Isolation Models
There are several common approaches to tenant isolation.
Separate Knowledge Stores
Each tenant receives an independent knowledge store.
Tenant A -> Store A
Tenant B -> Store B
Tenant C -> Store C
Advantages:
Strong isolation boundary
Easier tenant-specific administration
Lower risk of cross-tenant retrieval
Disadvantages:
More infrastructure
More configuration
More operational overhead
Shared Store With Tenant Metadata
All documents are stored in one logical knowledge system.
Shared Store
|
+-- Tenant A
+-- Tenant B
+-- Tenant C
Every document carries tenant metadata.
Retrieval must enforce the tenant filter.
Advantages:
Easier centralized management
Potentially simpler operations
Better utilization of shared infrastructure
Disadvantages:
Authorization becomes critical
A filtering mistake can expose another tenant's data
Testing requirements are higher
Hybrid Isolation
Large or highly sensitive tenants may receive dedicated resources while smaller tenants share infrastructure.
Enterprise Tenant A -> Dedicated
Enterprise Tenant B -> Dedicated
Tenant C
Tenant D
Tenant E
|
v
Shared Knowledge Layer
This can balance isolation and operational cost.
Retrieval Authorization
The core rule should be straightforward:
RetrievedDocument.TenantId
==
Request.TenantId
But tenant ID alone may not be sufficient.
A more complete policy might be:
Tenant
AND Region
AND Classification
AND Role
AND Document Permission
Conceptually:
bool IsAuthorized(
TenantContext user,
KnowledgeDocument document)
{
return
user.TenantId == document.TenantId
&&
user.Region == document.Region
&&
document.AllowedRoles
.Any(role => user.Roles.Contains(role));
}
The actual authorization model should be aligned with the application's identity and enterprise access-control architecture.
Keep Authorization Outside the LLM
An LLM should not decide:
"This document belongs to another tenant,
but I think the user should be allowed to see it."
That decision must be deterministic.
The model can summarize authorized information.
It should not grant authorization.
This principle is especially important in agentic systems where the model may perform multiple retrieval operations.
Tenant-Aware Retrieval Pipeline
A complete request can follow this sequence:
1. Authenticate User
|
2. Resolve Tenant Context
|
3. Resolve Roles / Permissions
|
4. Build Retrieval Policy
|
5. Query Knowledge Layer
|
6. Apply Authorization
|
7. Return Authorized Context
|
8. Generate Answer
|
9. Record Audit Information
The knowledge layer should never receive an ambiguous request such as:
"Search for refund policy."
It should receive a request that includes the relevant authorization context.
Retrieval Context Object
A useful abstraction is:
public sealed record KnowledgeQuery(
string Query,
TenantContext Tenant,
int TopK);
Then:
public async Task<IReadOnlyList<KnowledgeDocument>>
SearchAsync(
KnowledgeQuery query,
CancellationToken cancellationToken)
{
var results = await SearchKnowledgeAsync(
query.Query,
cancellationToken);
return results
.Where(x =>
x.TenantId == query.Tenant.TenantId)
.Where(x =>
x.AllowedRoles.Any(
role => query.Tenant.Roles.Contains(role)))
.Take(query.TopK)
.ToList();
}
This illustrates the policy concept, but production systems should enforce filtering as close to the data source as the platform supports.
Filtering after retrieval can be unsafe if unauthorized documents have already crossed a trust boundary.
Why Post-Retrieval Filtering Can Be Dangerous
Consider:
Search Result
|
+-- Tenant A document
|
+-- Tenant B document
|
+-- Tenant A document
If the retrieval system returns all three documents and the application removes Tenant B afterward, unauthorized data has already entered the application process.
For strong isolation, prefer:
Authorized Query
|
v
Knowledge Store
|
v
Only Authorized Results
rather than:
Search Everything
|
v
Remove Unauthorized Results
The exact enforcement mechanism depends on the knowledge platform and identity model.
Metadata Design
Good metadata is essential for tenant-aware retrieval.
Useful fields can include:
| Metadata | Purpose |
|---|---|
| TenantId | Tenant isolation |
| DocumentId | Traceability |
| User/Group permissions | Authorization |
| Region | Data residency |
| Classification | Security policy |
| Department | Business filtering |
| DocumentType | Retrieval filtering |
| CreatedAt | Lifecycle filtering |
| Version | Content consistency |
| Source | Provenance |
Join the conversation! Your thoughts help the community grow.