Install the free PostgreSQL
extension for VS Code
Connect a database and run every move from the series in under 20 minutes. Works with Azure HorizonDB,
Azure Database for PostgreSQL, or any other PostgreSQL database.
What the extension does
Connect and explore
Add a connection and browse databases, schemas, and tables.
AI-assisted query writing
Schema-aware IntelliSense with connected database context.
Ask @pgsql
Get Copilot answers grounded in your connected database.
Agent mode, with approval
Let Copilot work through an unfamiliar schema.
Why the editor
Your whole PostgreSQL workflow, in the editor you already use
Stay in flow
Connect, query, and manage PostgreSQL where you already write code.
Write SQL that matches your schema
IntelliSense knows your connected database, so names and completions are right the first time.
Bring AI in on your terms
Ask @pgsql about your data. Agent mode can act, but only with your approval.
Diagnose and resolve issues
Open the Metrics Dashboard and Azure Advisor recommendations without switching tools.
Hands-on
Build a research agent
backed by PostgreSQL on Azure
Turn what you learned into a working agent: PostgreSQL as the vector store, a Microsoft Foundry agent as the brain, and real Washington State case law as the data.
Step 1: Set up your environment
Clone the repo, create a Python virtual environment, and add your keys to
.env.git clone https:// cd postgres-agentspip install -r requirements.txtgithub.com/ Azure-Samples/ postgres-agents Step 2: Enable the extensions
Allow-list
azure_aiandvectoron your Azure Database for PostgreSQL server, then create them.CREATE EXTENSION IF NOT EXISTS azure_ai;CREATE EXTENSION IF NOT EXISTS vector;Step 3: Load data and generate embeddings
Create the
casestable and embed the case opinions with Azure OpenAI. About 3–5 minutes.cd load_data python main.pycd ..Step 4: Give your agent a Postgres tool
vector_search_casesinlegal_agent_tools.pyruns a pgvector similarity search the agent can call.Step 5: Create and run the agent
Initialize the agent in your Microsoft Foundry project with gpt-4o-mini, and answer a real legal question end to end.
python src/simple_ postgres_ and_ ai_ agent.py Step 6: Test and iterate
Ask follow-up questions in the Microsoft Foundry playground and trace each step.
Keep going
Read the docs on Microsoft Learn (opens in a new tab)
Overview, connections and identity, query editor, Copilot integration, @pgsql chat participant, Agent mode, MCP server.
Explore more samples on the PostgreSQL Hub (opens in a new tab)
Learning pathways, solution accelerators, and community.
Rewatch the series on YouTube (opens in a new tab)
Full playlist on Microsoft Developer.
Get the VS Code ebook (opens in a new tab)
A guide to working with PostgreSQL in VS Code.
You watched the workflow.
Now it can live in your editor.
Free extension. Install it, connect a database, and ask @pgsql about your data.