Configure Guardrails and a Custom Blocklist in Microsoft Foundry

Lab overview

Instructions are a request; guardrails are a control. In this lab, you review the default guardrail Microsoft applies to every deployment, create a custom blocklist for a confidential project name, build your own guardrail that includes it, assign that guardrail to contoso-chat in place of the default, and verify the assignment in the playground.

Why you'd do this

The system prompt from lab 3 can tell the model not to discuss certain things, but a persistent user can talk it out of that, and a model can leak something it was never told to protect. Guardrails sit outside the model: they inspect what goes in and what comes out and block it before it reaches anyone, no matter what the prompt says. That's the difference between asking the model to behave and enforcing it, and it's why every Foundry deployment ships with Microsoft's default guardrail already attached.

The default guardrail covers the broad categories: hate, sexual, violent, and self-harm content at tunable severity levels, jailbreak attempts, and protected material such as copyrighted text and code. What it can't know is anything specific to your business. A blocklist fills that gap with exact terms you supply, which is the right tool for a confidential project name, an internal codename, a customer identifier, or anything else that should never appear in a help desk conversation. Severity filters catch categories; blocklists catch strings.

Because Microsoft's defaults are read-only, adding a blocklist means building a custom guardrail that keeps the default controls and layers the blocklist on top, then reassigning the deployment to it. A deployment can only have one guardrail at a time, so watch the last two steps closely: when contoso-chat disappears from Microsoft.DefaultV2, that's your proof the new controls are in force. Setting the blocklist to act on both user input and model output means the term gets caught whether someone asks about it or the model volunteers it.

For certification prep, this is the content safety material in AI-901 and the responsible AI and agent configuration objectives in AI-103.

Lab details

  • Default Guardrail: Microsoft.DefaultV2
  • Blocklist: contoso-confidential with the exact-match term Project Falcon
  • Custom Guardrail: contoso-helpdesk-guardrail
  • Blocklist Control: User input and Output, action Block
  • Assigned To: contoso-chat

Learning objectives

  1. Describe the controls in Microsoft's default guardrail and how severity-based filters differ from blocklists.
  2. Create a custom blocklist with an exact-match term.
  3. Build a guardrail that adds a blocklist to the default content safety controls.
  4. Assign a custom guardrail to a model deployment and verify it replaced the default.

Exam relevance

  • AI-901 — Microsoft Azure AI Fundamentals — AI agents and their components, grounding with your own data.
  • AI-103 — Developing AI Apps and Agents on Azure — create a prompt agent in Foundry Agent Service, agent instructions, tools, and versions.

How this lab fits into the project

This is lab 4 of 12 in the Contoso Knowledge Assistant project. Contoso's IT help desk fields the same policy questions all day, so over this series you'll build an AI agent that answers them from the company's own documents, then ground it, secure it, evaluate it, monitor it, and publish it to Teams. This lab adds the safety controls that instructions alone can't provide, including a blocklist for Contoso's confidential Project Falcon.

Step-by-step instructions

  1. Review the default guardrail:
    • From the Azure portal home page, click contoso-foundry-01, then click Go to Foundry portal.
    • Scroll down and click contoso-chat.
    • On the Build screen, click Guardrails in the left pane.
    • Select the Microsoft.DefaultV2 row and note that contoso-chat is assigned to it.
    • Expand Protected materials, Content safety, and Jailbreak to review the controls.
    • Note that Microsoft's default guardrails can't be edited.
  2. Create a blocklist:
    • Click the Blocklists tab, then Create blocklist.
    • Double-click the default name and type contoso-confidential.
    • Click the Term field, type Project Falcon, and click Add.
    • Click Create.
  3. Create a guardrail and add the blocklist control:
    • Click the Guardrails tab, then Create.
    • Review the default controls and check the Blocklists checkbox under Content harms.
    • Click the blocklists dropdown and select contoso-confidential.
    • Click Next.
  4. Assign and name the guardrail:
    • Select contoso-chat to add your model, then click Next.
    • Double-click the default guardrail name and type contoso-helpdesk-guardrail.
    • Scroll down and ensure the contoso-confidential blocklist is listed.
    • Click Create.
  5. Verify the guardrail:
    • Click the contoso-helpdesk-guardrail row and note contoso-chat under Applied to.
    • Expand Content safety (5) and note the contoso-confidential (Blocklist) row, with User input and Output as intervention points and Block as the action.
    • Click the Microsoft.DefaultV2 row and note that contoso-chat is no longer assigned to it.
  6. Confirm the assignment in the playground:
    • Click the contoso-helpdesk-guardrail row, then Try in playground.
    • Expand the Guardrail section and scroll down.
    • Note the name contoso-helpdesk-guardrail, the risks with controls, and the risks without controls.
    • Click Microsoft Foundry to return to the home page.

An Introduction to Microsoft Entra ID

Learn what you need to know to get started with Microsoft Entra ID with this easily-digestible 5-hour bootcamp from best-selling instructor, Thomas Mitchell.

Disable these ads by becoming a labITpro Supporter!

Azure vNets Explained

Want to learn about Azure virtual networks? In this quick-hitting explanation, you’ll learn what they are, what they do, and you’ll learn about key Azure vNet features.

Disable these ads by becoming a labITpro Supporter!