Visual Studio Code Quick Start

Use DocumentDB for VS Code to connect to a local DocumentDB instance, browse sample data, and create your first database without leaving the editor.

Prerequisites

Install the extension

Install the extension from the VS Code marketplace, or run:

code --install-extension ms-azuretools.vscode-documentdb

If VS Code prompts you to reload after installation, do that before creating a connection.

Start DocumentDB first

For the fastest local setup, start DocumentDB Local with Docker:

docker run -dt --name documentdb \
  -p 10260:10260 \
  ghcr.io/documentdb/documentdb/documentdb-local:latest \
  --username <YOUR_USERNAME> \
  --password <YOUR_PASSWORD>

If you prefer a host installation instead of Docker, use Linux Packages Quick Start and complete the documentdb-setup step first.

Add a local connection in VS Code

  1. Open the DocumentDB view in the VS Code activity bar.
  2. In the local connection area, select DocumentDB Local and start the New Local Connection flow.
  3. Enter port 10260, your username, and your password.
  4. At the TLS/SSL prompt:
    • Choose Disable TLS/SSL (Not recommended) if you are using the default self-signed local setup and have not configured trust for the certificate yet.
    • Keep Enable TLS/SSL (Default) if you already configured a trusted local certificate.
  5. Finish the wizard and confirm the new connection appears in the connections tree.

Verify the connection in the extension

Once connected:

  1. Expand the connection and open sampledb if you started with DocumentDB Local sample data.
  2. Open a collection such as users or products.
  3. Switch between the Table, Tree, and JSON views to confirm the extension is reading data correctly.
  4. Create your own database and collection from the context menu, then add a test document like:
{
  "name": "VS Code Quick Start",
  "source": "vscode",
  "status": "connected"
}

If you prefer to validate outside the extension first, use Mongo Shell Quick Start.

Import, export, and querying

After the connection works, the extension can help you continue without leaving VS Code:

  • Import JSON documents into a collection
  • Export query results or full collections
  • Browse documents in multiple views with pagination
  • Open the query editor and continue with commands from the API Reference

Troubleshooting and debugging

If the extension does not connect on the first try:

  • Verify the extension is installed and reload VS Code if the DocumentDB view does not appear
  • Confirm your local DocumentDB instance is actually running before you connect
  • If you used Docker, check docker ps and docker logs documentdb
  • If you used Linux packages, check sudo systemctl status documentdb-gateway and sudo journalctl -u documentdb-gateway --no-pager -n 50
  • If the local connection wizard fails on security, retry and choose the TLS/SSL option that matches your certificate setup
  • Use mongosh to confirm the endpoint works independently of VS Code

For extension-specific help or bugs: