Query documents with Cosmos DB SQL
Runs a Cosmos DB SQL query against a container via the query_documents endpoint. Supply the container name, the query text, and optionally Meta to define result columns and types. Use for filtered or ordered queries, or when you need a custom SELECT. Cross-partition and scan behavior can be set in WITH.
For query syntax see Cosmos DB SQL query reference.
SELECT *
FROM query_documents
WITH(
-- Database='TestDB', --if you dont supply connection level Default Database name is used
Table='TestContainer',
Query='select * from root Where root.id!=null order by root._ts desc',
Meta='id:string(50);name:string(50);city;age'
--Meta='id; name; city; age' -- no types at all. Default is string(2000)
--Meta='id; name:string(50); city; age: int' --Mixed types. If type is missing default string(2000) used
--check below URL for more information on Query Language Syntax
--https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/select
)