The Azure Cosmos DB Shell Visual Studio Code extension provides a seamless, integrated experience for managing and querying your Cosmos DB databases directly from the code editor.
Installation
Method 1: VS Code Marketplace (recommended)
Open VS Code
- Launch Visual Studio Code on your machine
Open Extensions Marketplace
- Click the Extensions icon (Ctrl+Shift+X / Cmd+Shift+X)
- Or go to View > Extensions
Search for Cosmos DB
- Type "Cosmos DB" in the search box
- Look for the "Azure Cosmos DB" extension by Microsoft
Install the Extension
- Click the Install button
- Wait for installation to complete
- Reload VS Code if prompted
Method 2: Install from VSIX file
Download Extension
- Download
vscode-cosmosdb-0.33.3.vsix(or latest version) from the releases
- Download
Install Extension
- Open VS Code
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
- Click the "..." menu and select "Install from VSIX"
- Select the downloaded file
Complete Installation
- Wait for the installation to finish
- Reload VS Code if prompted
Requirements
- VS Code Version: 1.85 or later
- Supported Platforms: Windows, macOS, Linux
- Disk Space: ~50 MB
Features
1. Resource explorer
Explore your Cosmos DB resources in a hierarchical tree view.
Features:
- View all databases in your account
- See containers and their properties
- Browse documents within containers
- Display partition key and indexing information
Access:
- Click the Cosmos DB icon in the Activity Bar
- Or go to View > Cosmos DB Explorer
2. Quick launch
Launch Cosmos DB Shell directly from VS Code.
Methods:
Command Palette
- Press Ctrl+Shift+P (Cmd+Shift+P on macOS)
- Type "Cosmos DB Shell: Open"
- Press Enter
Explorer Context Menu
- Right-click on a database or container
- Select "Open in Shell"
Status Bar
- Click the Cosmos DB icon in the status bar
3. Command palette integration
Execute Cosmos DB Shell commands directly from the command palette.
Available Commands:
Cosmos DB Shell: Open- Launch the shellCosmos DB Shell: Connect- Switch accountsCosmos DB Shell: Disconnect- Close connectionCosmos DB Shell: Start MCP Server- Enable MCPCosmos DB Shell: Stop MCP Server- Disable MCPCosmos DB Shell: Settings- Access extension settings
Access Commands:
- Press Ctrl+Shift+P (Cmd+Shift+P)
- Type the command name
- Press Enter
4. Azure account integration
Seamlessly integrate with your Azure accounts.
Features:
- Automatic authentication with Azure account
- Support for multiple subscriptions
- Managed identity integration
- Microsoft Entra ID support
Configuration:
- Sign in with your Azure account (prompted on first use)
- Select subscription and resource group
- Choose Cosmos DB account to connect
5. MCP server integration
Enable Model Context Protocol server for AI integration.
Access:
- Open command palette (Ctrl+Shift+P)
- Type "Cosmos DB: Start MCP Server"
- Configure settings in VS Code settings.json
Configuration:
{
"cosmosDB.shell.MCP.enabled": true,
"cosmosDB.shell.MCP.port": 6128,
"cosmosDB.shell.MCP.startOnLaunch": true
}
Getting started
Step 1: Install the extension
Follow the Installation section above.
Step 2: Connect to your account
- Click the Cosmos DB icon in the Activity Bar
- Sign in with your Azure account (if prompted)
- Select your subscription and Cosmos DB account
- The Resource Explorer displays your databases and containers
Step 3: Open Cosmos DB Shell
- Press Ctrl+Shift+P (Cmd+Shift+P)
- Type "Cosmos DB Shell: Open"
- Press Enter to launch the integrated shell
Step 4: Start querying
# Navigate to a database
> cd mydb
# List containers
> ls
# Query documents
> query "SELECT * FROM c"
Working with resources
Explore databases
In Resource Explorer:
- Expand your Cosmos DB account
- View all databases
- Expand a database to see containers
- Right-click for context menu options
Available Actions:
- Create database
- Delete database
- Create container
- Refresh
Work with containers
Right-click Container Options:
- Open in Shell - Launch shell in container context
- Query Documents - Execute SQL query
- Create Document - Add new document
- Delete Container - Remove container
- View Properties - Display container metadata
Manage documents
Document Operations:
- View document contents
- Create new documents
- Update documents
- Delete documents
- Copy document ID
Integrated terminal
Use the integrated terminal for shell operations.
Launch terminal
- View > Integrated Terminal (Ctrl+`)
- Or click the Terminal tab at the bottom
Run commands
# In the integrated terminal
cosmosdbshell
# Navigate and query
> cd mydb
> ls
> query "SELECT * FROM c"
Settings and configuration
Access extension settings
- Open Settings (Ctrl+, / Cmd+,)
- Search for "Cosmos DB"
- Modify settings as needed
Available settings
| Setting | Default | Description |
|---|---|---|
cosmosDB.autoconnect |
true |
Auto-connect on startup |
cosmosDB.shell.MCP.enabled |
false |
Enable MCP server |
cosmosDB.shell.MCP.port |
6128 |
MCP server port |
cosmosDB.editor.theme |
dark |
Editor color theme |
cosmosDB.queryTimeout |
30000 |
Query timeout (ms) |
Example configuration
{
"cosmosDB.autoconnect": true,
"cosmosDB.shell.MCP.enabled": true,
"cosmosDB.shell.MCP.port": 6128,
"cosmosDB.queryTimeout": 60000
}
Keyboard shortcuts
| Action | Shortcut |
|---|---|
| Open Command Palette | Ctrl+Shift+P (Cmd+Shift+P) |
| Open Integrated Terminal | Ctrl+` |
| Toggle Sidebar | Ctrl+B (Cmd+B) |
| Close Editor | Ctrl+W (Cmd+W) |
| Copy | Ctrl+C (Cmd+C) |
| Paste | Ctrl+V (Cmd+V) |
Tips and tricks
1. Quick access to frequently used containers
- Click star icon next to container name
- Container appears in "Favorites" section
- Quick access without expanding tree
2. Multi-container queries
Use multiple terminal tabs to work with different containers:
- Open terminal (Ctrl+`)
- Right-click to create new terminal tab
- Connect to different containers in each tab
3. Save query results
Export query results to file:
# In integrated terminal
query "SELECT * FROM c" > results.json
4. Format JSON output
Use jq in the integrated terminal:
query "SELECT * FROM c" | jq '.[]'
5. Keyboard navigation
- Tab: Move between panels
- Arrow keys: Navigate tree
- Enter: Open selected item
- Delete: Delete selected resource
Troubleshooting
Extension won't load
Issue: Cosmos DB extension doesn't appear in VS Code
Solutions:
Verify VS Code version is 1.85 or later
Check extension is installed:
- Go to Extensions (Ctrl+Shift+X)
- Search "Cosmos DB"
- Verify the "Azure Cosmos DB" extension by Microsoft is installed
Restart VS Code
Clear extension cache:
- Delete
.vscode/extensionsfolder - Reinstall extension
- Delete
Can't connect to account
Issue: "Sign in required" or authentication fails
Solutions:
- Open command palette (Ctrl+Shift+P)
- Type "Azure: Sign Out"
- Type "Azure: Sign In"
- Complete browser authentication
- Select subscription and resource group
MCP server won't start
Issue: MCP server fails to start in extension
Solutions:
Check port 6128 is not in use:
# Windows netstat -ano | findstr 6128 # macOS/Linux lsof -i :6128Try different port in settings:
"cosmosDB.shell.MCP.port": 6129Check firewall settings
Review Output panel for errors
Shell doesn't respond
Issue: Cosmos DB Shell is frozen or unresponsive
Solutions:
- Try Ctrl+C to interrupt
- Close and reopen terminal
- Restart VS Code
- Check network connectivity
- Verify Cosmos DB account is accessible
Extension is slow
Issue: Extension is sluggish or resource-heavy
Solutions:
Disable auto-connect:
"cosmosDB.autoconnect": falseReduce refresh frequency
Close unnecessary explorer items
Check VS Code Activity Monitor (Help > About)
Disable other extensions if conflicting
Next steps
- Command Reference - Learn all available commands
- Quick Start Guide - Get started with examples
- Model Context Protocol Setup - Enable AI integration
- Troubleshooting Guide - Resolve issues
- Security Best Practices - Secure your setup