TIP

💡 Learn more : Azure Cosmos DB.

Querying documents properties with special characters in Cosmos DB

I was working with Cosmos DB yesterday and hit the following snag that I couldn't query my document that had special characters in it. Such is an example:

Notice the "$type": "mytype", has a $ in it.

If you head over to Query Explorer and try to query it using...

SELECT * 
FROM testing t
WHERE t.$type = 'mytype'
1
2
3

... then you'll see the following error:

I was able to fix this by wrapping the property inside [] such as...

SELECT * 
FROM testing t
WHERE t["$type"] = 'mytype'
1
2
3

Now my query returned properly