diff --git a/docs/Testing/ai-foundry-integration.md b/docs/Testing/ai-foundry-integration.md new file mode 100644 index 0000000000..0601199bbc --- /dev/null +++ b/docs/Testing/ai-foundry-integration.md @@ -0,0 +1,85 @@ +# Deploying Data API Builder (DAB) MCP Server and Integrating with Azure AI Foundry + +This document provides an end‑to‑end guide to stand up a **Data API Builder (DAB)** container that exposes **REST**, **GraphQL**, and **Model Context Protocol (MCP)** endpoints, and to integrate those endpoints with an **Azure AI Foundry Agent**. + +## 1. Architecture Overview + +**Components** +- **Azure SQL Database** hosting domain tables and stored procedures. +- **DAB container** (Azure Container Instances in this guide) that: + - reads `dab-config.json` from an **Azure Files** share at startup, + - exposes **REST**, **GraphQL**, and **MCP** endpoints. +- **Azure Storage (Files)** to store and version `dab-config.json`. +- **Azure AI Foundry Agent** configured with an **MCP tool** pointing to the DAB MCP endpoint. + +**Flow** +1. DAB starts in ACI → reads `dab-config.json` from the mounted Azure Files share. +2. DAB exposes `/api` (REST), `/graphql` (GraphQL), and `/mcp` (MCP). +3. Azure AI Foundry Agent invokes MCP tools to read/update data via DAB’s surface (entities and stored procedures). + + +## 2. Prerequisites +- Azure Subscription with permissions for Resource Groups, Storage, ACI, and Azure SQL. +- Azure SQL Database provisioned and reachable from ACI. +- Azure CLI (`az`) and .NET SDK installed locally. +- DAB CLI version **1.7.81 or later**. +- Outbound network access from ACI to your Azure SQL server. + + +## 3. Prepare the Database +Create tables and stored procedures: +- Tables +- Stored Procedures + +## 4. Install DAB CLI and Bootstrap Configuration +``` +dotnet tool install --global Microsoft.DataApiBuilder --version 1.7.81 +export DATABASE_CONNECTION_STRING="Server=.database.windows.net;Database=;User ID=;Password=;Encrypt=True;" + +dab init \ + --database-type "mssql" \ + --connection-string "@env('DATABASE_CONNECTION_STRING')" \ + --host-mode "Development" \ + --rest.enabled true \ + --graphql.enabled true \ + --mcp.enabled true \ + --mcp.path "/mcp" + +``` + +## 5. Add entities and stored procedure to `dab-config.json` and enable MCP tools in the config. + +## 6. Store dab-config.json in Azure Files +- Create a Storage Account and File Share. +- Upload dab-config.json. +- Record account name and key for mounting in ACI. + +## 7. Deploy DAB to Azure Container Instances + +``` +az container create \ + --resource-group \ + --name dab-mcp-demo \ + --image mcr.microsoft.com/azure-databases/data-api-builder:1.7.81-rc \ + --dns-name-label \ + --ports 5000 \ + --location \ + --environment-variables DAB_CONFIG_PATH="/aci/dab-config.json" \ + --azure-file-volume-share-name \ + --azure-file-volume-account-name \ + --azure-file-volume-account-key \ + --azure-file-volume-mount-path "/aci" + --os-type Linux \ + --cpu 1 \ + --memory 1.5 \ + --command-line "dotnet Azure.DataApiBuilder.Service.dll --ConfigFileName $configFile --LogLevel Debug" +``` +REST: http:///api/ +GraphQL: http:///graphql +MCP: http:///mcp + +## 8. Integrate with Azure AI Foundry +- Create or open a Project. +- Add an Agent. +- Add MCP tool with URL: http:///mcp. +- Test in Playground \ No newline at end of file