This mission brings together everything you've learned to build a complete, production-ready application with a modern frontend powered by AI-enhanced backend APIs. You'll configure Data API Builder (DAB) to expose your database as REST/GraphQL endpoints and integrate it with either a .NET or Python backend.
Your mission is to configure DAB to expose your product catalog, then run the full-stack application that combines:
- DAB for automatic REST/GraphQL APIs from your database
- Backend API (.NET or Python) for AI-powered chat and vector search endpoints
- Frontend for a user-friendly product search experience
- Configure Data API Builder: Set up DAB to expose database entities as REST/GraphQL endpoints
- Use Environment Variables: Securely manage connection strings and API keys
- Integrate Multiple Services: Connect DAB, backend API, and frontend together
- Test Full-Stack Applications: Verify end-to-end functionality
- Missions 1-3 completed (embeddings, RAG, and orchestration)
- SQL Server with the
walmart_ecommerce_product_detailstable and stored procedures:get_embedding- Generates embeddings using AI_GENERATE_EMBEDDINGS()get_similar_items- Performs vector similarity search
- External Model
MyEmbeddingModelcreated (from Mission 1) - Choose your backend:
- .NET: .NET 9+ SDK installed
- Python: Python 3.10+ with pip
├── .env # Environment variables (connection strings, API keys)
├── README.md # This file
├── dab-config.json # DAB configuration
├── frontend/
│ └── index.html # Single-page frontend application
├── dotnet/ # .NET backend
│ ├── Program.cs # .NET Minimal API with AI endpoints
│ ├── SqlAiApp.csproj # Project file
│ ├── start.ps1 # Windows startup script
│ └── start.sh # Linux/macOS startup script
└── py/ # Python backend
├── main.py # FastAPI with AI endpoints
├── requirements.txt # Python dependencies
├── start.ps1 # Windows startup script
└── start.sh # Linux/macOS startup script
dotnet tool install -g Microsoft.DataApiBuilderVerify installation:
dab --versionCreate or update the .env file in the mission4 folder:
# Database connection
SERVER_CONNECTION_STRING=Server=YOUR_SERVER;Database=YOUR_DATABASE;Trusted_Connection=yes;TrustServerCertificate=yes;
# Azure OpenAI
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
MODEL_API_KEY=your-api-key-hereThe dab-config.json file is located in the mission4 folder (not inside dotnet or py).
cd mission4
dab init --database-type mssql --connection-string "@env('SERVER_CONNECTION_STRING')" --host-mode developmentdab add Products --source "dbo.walmart_ecommerce_product_details" --permissions "anonymous:read"Edit dab-config.json to allow requests from the .NET app:
{
"runtime": {
"host": {
"cors": {
"origins": ["http://localhost:5001", "http://localhost:3000", "http://127.0.0.1:5001", "http://localhost:8000", "http://127.0.0.1:8000"],
"allow-credentials": true
},
"mode": "development"
}
}
}Your final configuration should look similar to:
{
"$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json",
"data-source": {
"database-type": "mssql",
"connection-string": "@env('SERVER_CONNECTION_STRING')"
},
"runtime": {
"rest": {
"enabled": true,
"path": "/api"
},
"graphql": {
"enabled": true,
"path": "/graphql",
"allow-introspection": true
},
"host": {
"cors": {
"origins": ["http://localhost:5001", "http://localhost:3000", "http://127.0.0.1:5001", "http://localhost:8000", "http://127.0.0.1:8000"],
"allow-credentials": true
},
"mode": "development"
}
},
"entities": {
"Products": {
"source": {
"object": "dbo.walmart_ecommerce_product_details",
"type": "table"
},
"permissions": [
{
"role": "anonymous",
"actions": ["read"]
}
]
}
}
}Choose either the .NET or Python backend based on your preference.
Windows (PowerShell):
cd dotnet
.\start.ps1Linux/macOS (Bash):
cd dotnet
chmod +x start.sh
./start.shThis script:
- Loads environment variables from
.env - Starts DAB on port 5000
- Starts the .NET API on port 5001
- Opens the frontend in your browser
Terminal 1 - Start DAB:
cd mission4
dab startTerminal 2 - Start .NET API:
cd dotnet
dotnet runBrowser:
Open http://localhost:5001/app
cd py
pip install -r requirements.txtWindows (PowerShell):
cd py
.\start.ps1Linux/macOS (Bash):
cd py
chmod +x start.sh
./start.shThis script:
- Loads environment variables from
.env - Starts DAB on port 5000
- Starts the FastAPI server on port 8000
- Opens the frontend in your browser
Terminal 1 - Start DAB:
cd mission4
dab startTerminal 2 - Start Python API:
cd py
python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reloadBrowser:
Open http://localhost:8000/app
| Service | URL | Description |
|---|---|---|
| Frontend | http://localhost:5001/app | Product search UI |
| Swagger | http://localhost:5001/swagger | API documentation |
| DAB REST | http://localhost:5000/api/Products | Direct database access |
| DAB GraphQL | http://localhost:5000/graphql | GraphQL playground |
| Service | URL | Description |
|---|---|---|
| Frontend | http://localhost:8000/app | Product search UI |
| Swagger | http://localhost:8000/docs | API documentation |
| DAB REST | http://localhost:5000/api/Products | Direct database access |
| DAB GraphQL | http://localhost:5000/graphql | GraphQL playground |
- Browse Products: Click the "Browse Products" tab to see paginated results from DAB
- Vector Search: Use the "Vector Search" tab to find products using semantic similarity
- AI Chat: Ask the AI assistant questions like "I need a gaming laptop"
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Frontend │────▶│ Backend API │────▶│ Azure OpenAI │
│ │ │ (.NET or Python)│ │ │
└─────────────────┘ └────────┬────────┘ └─────────────────┘
│
┌────────────────────────┼────────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ DAB │ │ SQL Server │ │ Vector Search │
│ (port 5000) │────▶│ (Database) │◀────│ (Stored Procs) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
Port Summary:
- DAB: Port 5000 (both backends)
- .NET API: Port 5001
- Python API: Port 8000
- Check that
SERVER_CONNECTION_STRINGenvironment variable is set - Verify the connection string format and server accessibility
- Ensure no other process is using port 5000
- Verify DAB is running:
curl http://localhost:5000/api/Products - Check CORS configuration in
dab-config.json - Ensure the table
dbo.walmart_ecommerce_product_detailsexists
- Verify the
get_similar_itemsstored procedure exists - Check that embeddings are populated in the database
- Ensure the external model
MyEmbeddingModelis created - Verify Azure OpenAI credentials are correct in
.env
- Check Azure OpenAI endpoint and API key in
.env - Verify the
gpt-5-minimodel is deployed - Check the backend logs for error messages
After completing this mission, you have a production-ready, AI-powered full-stack application! Consider:
- Add More Entities: Expose additional tables or views through DAB
- Implement Authentication: Add Azure AD or JWT authentication to DAB
- Deploy to Azure: Use Azure Static Web Apps + Azure SQL + Azure Container Apps
- Add Analytics: Track usage patterns and popular queries
- Open Hack: Use this foundation for the Week 4 Open Hack challenge!
