How to secure AI workloads and agents
From an AI bill of materials to agent identity, governed RAG sources, prompt injection protection, and a release gate on GA and preview.
- 01
Build an AI bill of materials first
Most organisations cannot answer the question "what AI is running in my tenant". As long as that is true, every security control is a guess about the set it applies to. AI security posture management does the inventory: it finds Azure OpenAI, Microsoft Foundry and Azure Machine Learning (as well as Amazon Bedrock and Google Vertex AI) and assembles an AI bill of materials from them.
The inventory is the start, not the answer. Record per AI workload who owns it, which data sources it touches, which identities it runs as, which tools it may call, where it logs and who gets called during an incident. Do that before the workload reaches production, not after.
The three Zero Trust principles hold without change, but what they mean shifts. Verifying explicitly now also covers an agent acting on someone's behalf. Least privilege covers the tools an agent is allowed to call. And assuming breach means this: assume that at some point a model receives an instruction that did not come from you.
Pitfallno AI BOM. Unknown AI components stay unknown, and the first time you see them is during an incident. AI SPM discovery costs you a plan, not a project. - 02
Give every agent an identity, an owner and least privilege
An agent is not a function but an acting party. It therefore needs what an employee needs: its own identity in Microsoft Entra, a sponsor who is accountable, a lifecycle with periodic review, and a permission set no larger than its task.
Four things go wrong here in practice, and they reinforce each other:
- No registry. Without central registration, shadow agents proliferate just as fast as shadow SaaS, and nobody knows how many there are. Agent 365 is the layer that observes, governs and secures agents.
- No owner. An agent without a sponsor keeps running after the project ends and the risk sits with nobody.
- No least privilege. An agent with broad permissions increases the blast radius of every incident it is involved in. Entra, Conditional Access and agent lifecycle controls are the knobs here.
- No view of tool use. An authorised tool can be abused too; the question is not whether the agent may call it but whether this pattern of calls makes sense. That is what runtime detection is for.
Decisionwho may put an agent into production? If the answer is "anyone with a licence", then a registry is an administration after the fact rather than a gate before it. Record who signs off before the first agent goes live. - 03
Build RAG on sources that are already governed
Retrieval augmented generation is not a security problem in itself. The problem starts at the source: a model that may read what an employee may not see will hand that back in an answer sooner or later. So design RAG on labelled sources with working access control, not on a data dump staged "for now".
The order is the point. Classify and label with Microsoft Purview, turn on DLP and make sure lineage is right, and only then set up the grounding. The other way round does not work: a label applied afterwards changes nothing about the answers already given.
For Microsoft 365 Copilot the SharePoint and OneDrive legacy comes on top of that. Copilot sees what the user may see, so every item shared too widely is an answer waiting for the right question. Oversharing is not created by AI, but it is made visible by it, and then at AI speed.
Recommendationtreat "which sources may be used for grounding" as an architecture decision with an owner, not as a configuration field in the project. The list should be shorter than what is technically possible. - 04
Separate model safety from data security, and do both
These are two different disciplines and they do not replace each other. Model safety is about the model and the artifact: is this model safe, does it come from a trusted source, was it scanned before it was registered? Data security is about what goes in and comes out: which data does the model touch, who may see it, how long do you keep it?
For registered models in Azure Machine Learning there is AI model security, and you enable it where it is available. Without model scanning an unsafe model simply reaches production, and from then on data security is only guarding the damage.
Importantan organisation that only sets up data security believes it is done. The reverse happens too: an MLOps team that scans models diligently and has explained the data flow underneath to nobody. Both implementations are half. - 05
Enable runtime protection against prompt injection and exfiltration
Threat protection for AI recognises the attack patterns specific to generative AI: data leakage, data poisoning, jailbreak and credential theft. The alerts land in the same stream as everything else, so your SOC needs no separate process for them.
Prompt injection is the attack most often misunderstood. It is not phishing where a human does something wrong; it is an instruction arriving through a channel the model reads and the user does not. Email is the most underestimated channel here: if an assistant reads mail, every inbound message is a possible instruction. Defender for Office 365 has detection for that, and you enable it the moment AI reads along in the mail flow.
Also look explicitly at which AI endpoints are reachable from outside. Every externally reachable endpoint widens the attack path; authentication and least privilege come before every other control there.
Noteaccording to Microsoft's availability table, threat protection for AI supports text tokens only. In a multimodal application, image and audio therefore sit outside this protection. Put that boundary in the design instead of discovering it later. - 06
Treat prompts and responses as data
A prompt is user input and a response is system output, and both can contain data that appears nowhere else in your logging. So they belong under the same rules as the rest of your data: audit, retention, eDiscovery and DLP where supported. Microsoft Purview is where that happens.
That cuts both ways. Capturing without governance is itself a risk: you create a new collection of personal data with no owner, no retention period and no role restriction. So enable suspicious prompt evidence only once you have worked through the privacy and compliance consequences and restricted the roles allowed to read it.
Decisionwho may read prompts? That is a different question from who may read security alerts, and the answer should be a smaller group. - 07
Put a release gate on GA, preview and licensing
The AI security landscape moves faster than any other part of the Microsoft stack. Capabilities move from preview to GA, shift between licences and are not available in every cloud. An architecture that ignores that promises something the customer will not get.
Record three things per capability before you sign off a design: the release state, the licence it requires and the clouds it exists in. Do that as a table attached to the design and not as a footnote in a deck, because it is exactly the information that has to be rechecked six months later.
Pitfallselling preview as a commitment. It costs you twice: delivery misses the date, and the trust you built with the advice disappears in the same meeting.
Common mistakes
The ten that come back most often with AI workloads and agents:
| Mistake | Why it hurts | Better |
|---|---|---|
| No AI BOM | Unknown AI components remain | AI SPM discovery |
| No agent registry | Shadow agents grow unseen | Agent 365 with registration |
| Agents without owners | Orphaned risk persists | Sponsors and lifecycle reviews |
| Agents with broad rights | Larger blast radius per incident | Entra and Conditional Access |
| Tool misuse unseen | Even an allowed tool can harm | Runtime detection and blocking |
| RAG on ungoverned sources | Sensitive data leaks via grounding | Labels, DLP and lineage first |
| No model scanning | Unsafe models reach production | Enable AI model security |
| Prompt injection seen as phishing | The channel stays open | Detection on the AI mail flow |
| Capturing prompts with no policy | A new privacy risk is added | Audit, retention, RBAC |
| Promising preview as GA | Delivery and trust at risk | Record release state up front |
What to do next
This guide covers the layer where models, prompts and agents run. The platform underneath has its own choices; those are in How to secure a Data & AI platform with Microsoft Defender. You set up the classification and labels from step 3 with How to set up Microsoft Purview data governance, and the wider trade-offs around a Copilot rollout are in Rolling out Microsoft 365 Copilot: remediating oversharing and governing agents.
The process at a glance
Click a step for its key decision
Build an AI bill of materials first
This step has no explicit decision, but builds on the previous one.
Read next
Related patterns
Related use cases
Related best practices
