Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/ai-foundry-toolbox.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions labs/ai-foundry-toolbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: AI Foundry Toolbox
architectureDiagram: images/ai-foundry-toolbox.gif
categories:
- AI Agents & MCP
- Knowledge & Tools
services:
- Azure AI Foundry
- Azure API Management
shortDescription: Secure and govern a Foundry Toolbox MCP endpoint with Azure API Management.
detailedDescription: A Foundry Toolbox bundles tools (MCP servers, Web Search, Azure AI Search, and more) into a single MCP-compatible endpoint. This lab shows how to place Azure API Management in front of that endpoint. APIM accepts subscription key auth from agents and transparently injects a managed-identity Entra token when forwarding requests to the Toolbox, so consumers never handle Foundry credentials directly. APIM also adds rate limiting, per-subscription monitoring, and policy-based governance over every tool call.
tags: []
authors:
- georgeollis
---

# APIM ❤️ AI Foundry

## [AI Foundry Toolbox lab](ai-foundry-toolbox.ipynb)

[![flow](../../images/ai-foundry-toolbox.gif)](ai-foundry-toolbox.ipynb)

A [Foundry Toolbox](https://learn.microsoft.com/azure/foundry/agents/how-to/tools/toolbox) is a managed resource in Azure AI Foundry that bundles tools—MCP servers, Web Search, Azure AI Search, Code Interpreter, and more—into a single MCP-compatible endpoint. This lab places Azure API Management in front of that endpoint, so agents use an APIM subscription key instead of managing Foundry credentials, while APIM enforces governance, rate limiting, and observability over every tool call.

Key scenarios covered:

- Deploy APIM and Azure AI Foundry using Bicep
- Deploy the vet-clinic and pet-insurance MCP servers as Azure Functions Flex Consumption apps (no container needed)
- Create a Foundry Toolbox with both MCP servers via the azure-ai-projects SDK
- Configure APIM native MCP proxy to the Toolbox MCP endpoint (subscription key → managed-identity Entra token)
- Verify tool discovery and run chat completions with Toolbox tools routed through APIM

### Prerequisites

- [Python 3.12 or later](https://www.python.org/) installed
- [VS Code](https://code.visualstudio.com/) installed with the [Jupyter notebook extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter) enabled
- [uv](https://docs.astral.sh/uv/) — run `uv sync` from the repo root to install dependencies
- [An Azure Subscription](https://azure.microsoft.com/free/) with [Contributor](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/privileged#contributor) + [RBAC Administrator](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/privileged#role-based-access-control-administrator) or [Owner](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/privileged#owner) roles
- [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) installed and [signed in to your Azure subscription](https://learn.microsoft.com/cli/azure/authenticate-azure-cli-interactively)

### 🚀 Get started

Proceed by opening the [Jupyter notebook](ai-foundry-toolbox.ipynb), and follow the steps provided.

### 🗑️ Clean up resources

When you're finished with the lab, you should remove all your deployed resources from Azure to avoid extra charges and keep your Azure subscription uncluttered.
Use the [clean-up-resources notebook](clean-up-resources.ipynb) for that.
664 changes: 664 additions & 0 deletions labs/ai-foundry-toolbox/ai-foundry-toolbox.ipynb

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions labs/ai-foundry-toolbox/clean-up-resources.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "50028a44",
"metadata": {},
"source": [
"### 🗑️ Clean up resources\n",
"\n",
"When you're finished with the lab, you should remove all your deployed resources from Azure to avoid extra charges and keep your Azure subscription uncluttered."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "12ead6d7",
"metadata": {},
"outputs": [],
"source": [
"import os, sys\n",
"sys.path.insert(1, '../../shared') # add the shared directory to the Python path\n",
"import utils\n",
"\n",
"deployment_name = os.path.basename(os.path.dirname(globals()['__vsc_ipynb_file__']))\n",
"resource_group = f\"lab-{deployment_name}\"\n",
"\n",
"utils.cleanup_resources(deployment_name, resource_group_name=resource_group)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading