Microsoft Foundry โ€” MongoDB + Azure AI Samples

A collection of samples and reference architectures for building AI-powered applications with MongoDB Atlas and Microsoft Azure AI Foundry โ€” including retrieval-augmented generation (RAG), hosted agents, and Model Context Protocol (MCP) tool integrations.

What's Inside

Sample Description Technologies
simple-rag-movies Fully automated, single-script deployment of a Microsoft Foundry agent performing RAG over MongoDB Atlas movie data via MCP tools Microsoft Foundry, Azure Native MongoDB Atlas, Atlas Vector Search, MongoDB MCP Server, Azure Functions (Flex Consumption), Bicep, PowerShell

simple-rag-movies

Build a Microsoft Foundry agent that performs semantic search over MongoDB Atlas sample movie data โ€” deployed end to end with one script (./scripts/setup-and-deploy.ps1).

What the agent can do

What's included

โ†’ Full setup guide: simple-rag-movies/README.md

Architecture

The agent registers one MCP server โ€” the Azure Function โ€” which advertises semantic_search plus every tool the MongoDB MCP server offers. Calls that are not semantic_search are relayed to the MongoDB MCP server untouched, so the MCP server performs all database operations and is the only component holding the connection string. The Function has no MongoDB driver and no database credentials โ€” it only embeds the user query.

Microsoft Foundry + MongoDB Atlas reference architecture

Prerequisites

๐Ÿ’ก No Functions Core Tools or local Python needed
The deploy script uses Flex Consumption, which builds the function remotely โ€” and it creates the Foundry project, model deployment, and agent for you.

Quick Start

Option A โ€” GitHub Codespaces (fastest, zero local install)

Open in GitHub Codespaces

The dev container preinstalls Azure CLI, PowerShell, Python, Bicep, and the MongoDB Atlas CLI. Then run one command:

./scripts/setup-and-deploy.ps1

Option B โ€” Local

git clone https://github.com/mongodb-partners/Microsoft_Foundry.git
cd Microsoft_Foundry/simple-rag-movies
./scripts/setup-and-deploy.ps1

You're prompted to sign in to Azure and MongoDB Atlas (browser device-code login); the script then sets up Atlas + Azure + the agent end to end.

Test the agent

Open mongodb-search-agent in the Foundry playground and try:

Repository Structure

Microsoft_Foundry/
โ”œโ”€โ”€ index.html                       # This documentation site (GitHub Pages)
โ”œโ”€โ”€ README.md                        # Hub overview
โ”œโ”€โ”€ MSFT Foundry_Architecture.png    # Reference architecture diagram
โ””โ”€โ”€ simple-rag-movies/               # Sample: Foundry agent + Atlas Vector Search RAG
    โ”œโ”€โ”€ README.md                    # Sample setup guide
    โ”œโ”€โ”€ LICENSE                      # Sample license
    โ”œโ”€โ”€ sample-queries.md            # Example queries to test the agent
    โ”œโ”€โ”€ deploy/                      # Bicep templates + config.example.json
    โ”œโ”€โ”€ docs/                        # Architecture doc and agent instructions
    โ”œโ”€โ”€ imgs/                        # Sample architecture diagram
    โ”œโ”€โ”€ scripts/                     # setup-and-deploy.ps1 + atlas/ and azure/ automation
    โ”œโ”€โ”€ src/embedding-function/      # Azure Function (Python) for embeddings
    โ””โ”€โ”€ .devcontainer/               # GitHub Codespaces dev container

Configuration

Embedding Function

SettingDescriptionDefault
AZURE_OPENAI_ENDPOINTAzure OpenAI resource endpointRequired
AZURE_OPENAI_API_KEYAzure OpenAI API keyRequired
EMBEDDING_MODELEmbedding model deployment nametext-embedding-ada-002

MCP Server

SettingDescriptionDefault
MDB_MCP_CONNECTION_STRINGMongoDB connection stringRequired
MDB_MCP_READ_ONLYRestrict to read operationstrue
MDB_MCP_HTTP_PORTHTTP port8080

Security

This repository follows security best practices:

โš ๏ธ If a secret is ever committed
Rotate it immediately and remove it from git history.

Resources