visual-studio-codeazure-cosmosdb

How to execute a query in VS Code for Cosmos DB?


I have installed an extension for having access to a Microsoft Azure Cosmos DB in VS Code, and I'm able to see the documents inside as expected.

enter image description here

However, I wasn't able to figure out how to run a query that allow me to filter results based on different conditions e.g: SELECT * FROM c WHERE c.DocumentId = 123

Is there a way to run SQL queries in VS Code on a Cosmos DB? I couldn't find any helpful tutorial and by installing "mssql" extension seems that is mainly focused on ADO.NET connections.


Solution

  • Based on the statements in the cosmos db extension:

    Browse and query your MongoDB databases both locally and in the cloud using scrapbooks with rich Intellisense then connect to Azure to manage your Cosmos DB databases with support for MongoDB, Graph (Gremlin), and SQL (previously known as DocumentDB).

    You could follow below official example of Scrapbooks to query your sql api db with mongo shell syntax.

    enter image description here

    E.G.

    db.coll.find({"DocumentId" :123})
    

    Update:

    Sorry for the late updates. I got 2 tools for you:

    1.CosmosDbExplorer :https://www.bruttin.com/CosmosDbExplorer/

    2.Azure Storage Explorer: https://azure.microsoft.com/en-us/features/storage-explorer/

    enter image description here