Edit

Connect Visual Studio Code to the local Azure Cosmos DB emulator

What this feature does

The extension can connect to a local emulator for offline or preproduction development.

Prerequisites

  • Azure Cosmos DB Emulator installed and running.
  • Visual Studio Code with the Azure Databases extension.

Connect to the emulator

  1. Start the Azure Cosmos DB Emulator on your machine.
  2. In Visual Studio Code, open the Azure view.
  3. Use the extension action to connect to a local emulator endpoint.
  4. Provide the emulator endpoint and key when prompted.

Screenshot of connect to local emulator dialog in Visual Studio Code for Azure Cosmos DB with endpoint and key fields.

Common local endpoint:

https://localhost:8081

Validate the connection

  1. Expand the emulator connection in the resource tree.
  2. Open a database and container.
  3. Run a quick query:
SELECT TOP 10 * FROM c

Troubleshooting

  • If TLS warnings appear, verify emulator certificates are trusted.
  • If connection fails, confirm the emulator is running before connecting.
  • If results are empty, verify that data exists in the local container.