Open links in new tab
  1. Azure Cosmos DB for NoSQL supports a SQL-like query language to retrieve and manipulate JSON documents. You can run these queries in the Azure Portal Data Explorer, SDKs, or REST API.

    Example – Retrieve all fields for a specific document:

    SELECT *
    FROM Families f
    WHERE f.id = "WakefieldFamily"
    Copied!

    This returns the complete JSON document where the id matches "WakefieldFamily".

    Filtering and Projection You can filter documents using WHERE and return only specific fields:

    SELECT c.givenName
    FROM Families f
    JOIN c IN f.children
    WHERE f.id = "WakefieldFamily"
    Copied!

    This uses a JOIN to iterate over the children array and returns only their givenName values.

    String Matching Cosmos DB SQL supports functions like CONTAINS, STARTSWITH, and ENDSWITH for text search:

    SELECT s.Cars, s.Class
    FROM s
    WHERE CONTAINS(s.Cars, "ECO")
    Copied!

    For case-insensitive search, wrap both sides with UPPER().

    Null and Missing Property Handling Use IS_NULL() to check for null values and IS_DEFINED() to check if a property exists:

    SELECT s.InvoiceNumber,
    (IS_DEFINED(s.LineItemDiscount) ? s.LineItemDiscount : 0) AS Discount
    FROM s
    Copied!
  1. Query language for Cosmos DB (in Azure and Fabric) documentation

    Learn about the query language for Cosmos DB used in products like Azure Cosmos DB and Cosmos DB in Fabric. Use familiar ANSI SQL keywords to query loosely structured data.

  2. Querying An Azure Cosmos DB Database using the SQL API

    In this lab, you will query an Azure Cosmos DB database instance using the SQL language. You will use features common in SQL such as projection using SELECT statements and filtering using WHERE …

  3. Azure Cosmos DB Workshop - Querying in Azure Cosmos DB

    Querying JSON with SQL allows Azure Cosmos DB to combine the advantages of a legacy relational databases with a NoSQL database. You can use many rich query capabilities such as sub-queries or aggregation functions but still retain the many advantages of modeling data in a NoSQL database. Azure Cosmos DB supports strict JSON items only…
    See more on azurecosmosdb.github.io
  4. Tutorial: Query Data - Azure Cosmos DB | Microsoft Learn

    Dec 19, 2025 · Learn how to query data in Azure Cosmos DB for NoSQL with the built-in query syntax using the Data Explorer.

  5. Azure Cosmos DB SQL API Explained: Beginner Guide to …

    Jun 23, 2025 · In this guide, I’ll explain what the Cosmos DB SQL API is, why it matters, and how it works. You’ll learn about key features, simple terms, and how …

  6. Tutorial: Query Data - Azure Cosmos DB | Azure Docs

    Jan 14, 2026 · Learn how to query data in Azure Cosmos DB for NoSQL with the built-in query syntax using the Data Explorer.

  7. People also ask
    Loading
    Unable to load answer
  8. Cheat Sheet for Cosmos DB SQL queries · GitHub

    Jan 18, 2026 · Cheat Sheet for Cosmos DB SQL queries. GitHub Gist: instantly share code, notes, and snippets.

  9. Execute a query with the Azure Cosmos DB for NoSQL SDK

    In this lab, you’ll use an iterator to process a large result set returned from Azure Cosmos DB for NoSQL. You will use the Python SDK to query and iterate over results.

  10. SQL Queries in Azure Cosmos DB - Part 1 - RedBit Dev

    In this article, we'll see the queries used in Azure Cosmos DB SQL API and how to use Structured Query Language (SQL) as it’s one of the most familiar and known query …

  11. Deploy and Query Azure Cosmos DB with the NoSQL API

    Create a serverless Cosmos DB account, build a database and container, insert and query documents, and explore consistency levels in this hands-on lab.