'Cosmos SQL find items which has a string in array

I'm trying to write a query in CosmosDB using SQL for the following scenario. Let say I have a collection with items as follows

{
   "resource": "abc",
   "region": "east",
   "tags": ["tag1", "tag2"]
}

{
   "resource": "def",
   "region": "east",
   "tags": ["tag1", "tag2"]
}

{
   "resource": "xyz",
   "region": "east",
   "tags": ["tag3"]
}

now I want to write a query that return all items that has a string "tag1" in tags property (I want to get/project all the properties in that item)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source