In this hands-on lab, youβll build an AI-powered legal research assistant that reasons over real-world case law data using PostgreSQL and Microsoft Agent Framework. Youβll learn how to combine retrieval-augmented generation (RAG), vector search, and graph intelligence to develop an agentic workflow capable of generating accurate, contextual, and explainable answers β all running on Azure Database for PostgreSQL.
By the end of this lab, you will be able to:
- Configure Azure Database for PostgreSQL Flexible Server with AI extensions (
azure_ai,pgvector,diskann, andapache_age) - Use Microsoft Agent Framework to build autonomous agents with database and web plugins
- Implement semantic search and reranking using vector embeddings
- Enhance reasoning quality using the GraphRAG pattern
- Deploy your AI agent and supporting infrastructure on Azure using Bicep and CLI automation
- Azure Database for PostgreSQL Flexible Server (with AI extensions)
- Microsoft Agent Framework (for agent orchestration)
- Azure OpenAI Service (embeddings + LLM completions)
- Python (agent runtime and notebook execution)
- Apache AGE (for graph storage and reasoning)
- DiskANN (for fast approximate vector similarity search)
- VS Code PostgreSQL Extension (for hands-on queries and debugging)
User Query β Microsoft Agent Framework β PostgreSQL (Vector + Graph + AI) β Azure OpenAI β Contextual Answer- Microsoft Agent Framework: Handles reasoning, plugin invocation, and dialogue context.
- PostgreSQL: Stores case law data, embeddings, and graph relationships.
- GraphRAG: Uses Apache AGE to connect related entities and improve recall.
- Azure OpenAI: Powers embeddings and completion for semantic responses.
-
Setup Azure PostgreSQL Database:
- Database connection and configuration
- Install the
azure_aiextension - Configure Azure OpenAI connectivity
-
Using AI-driven features in PostgreSQL:
- Pattern matching queries
- Semantic vector search using embeddings
- DiskANN indexing for fast vector similarity search
-
Building the Agent Application:
- Setting up Microsoft Agent Framework
- Creating database search plugins
- Implementing semantic reranking
- Adding external data sources
- Testing and improving the agent
| Folder | Description |
|---|---|
Code/ |
Core Jupyter notebooks and sample scripts |
Dataset/ |
Sample dataset (cases.csv) for legal research queries |
Scripts/ |
Source code for agents, plugins, and database connectors |
Docs/ |
Step-by-step lab manual and architecture guide |
Docs/images |
Architecture and concept diagrams |
infra/ |
Deployment templates (Bicep + PowerShell scripts) |
- Ensure you have an Azure subscription with access to Azure OpenAI.
- Install required CLI tools:
azd auth login
azd env new
azd provisionThis will deploy the Azure resources (PostgreSQL + OpenAI) and generate a .env file containing connection details.
Use the provided scripts in Scripts/ to:
- Initialize tables and vector indexes
- Load the sample case law dataset
- Enable azure_ai, pgvector, and apache_age extensions
Open Code/lab.ipynb in Visual Studio Code and follow the guided steps to:
- Connect to your database
- Generate embeddings
- Execute semantic and graph-based queries
- Interact with your AI Agent
| Resource | Link | Description |
|---|---|---|
| Ignite 2025 Next Steps | https://aka.ms/Ignite25-Next-Steps | Links to all repos for Ignite 2025 Sessions |
| Learn at Ignite | https://aka.ms/LearnAtIgnite | Continue learning on Microsoft Learn |
| GraphRAG for PostgreSQL | https://aka.ms/pg-graphrag | Learn how to add graph intelligence to Postgres |
| VS Code PostgreSQL Extension | https://aka.ms/pgsql-vscode | Learn more about the PostgreSQL extension |
![]() Varun Dhawan π’ |
![]() Jonathon Frost π’ |
![]() Jared Meade π’ |
![]() Gauri Kasar π’ |
Ready to build, experiment, or scale your next project? Kick things off with an Azure Free Trial and get access to popular services, generous monthly credits, and the tools you need to ship fast. π Start your free journey here: https://aka.ms/devrelft
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit Contributor License Agreements.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.





