Skip to main content


Add more security to an Azure CosmosDB Account.

Recent posts

Querying CosmosDB. Part 3

Hi guys !!!

We continue with "Querying CosmosDB" series. You can read previous parts in Part1 and Part 2.

Now we added event notes to some documents. It's means some speakers added short notes or tags to theirs events. You can download a new version of our JSON Example (JSON Example 2)

Show me please !!

Ok. Fine !! Retrieve a list of all events with notes. Query

SELECT c.event_name, c.speaker, c.event_notes FROM c where IS_DEFINED(c.event_notes)


I don't want all notes, just with 'pool' word.

SELECT c.speaker, c.event_name, c.event_notes FROM c JOIN notes IN c.event_notes where IS_DEFINED(c.event_notes) AND CONTAINS(notes,"pool")

I don't care about event name or speakers. Let me list just notes!!!

SELECT notes FROM c JOIN notes IN c.event_notes


Please just a list, not object list!!!

SELECT VALUE notes FROM c JOIN notes IN c.event_notes

Bye !!!! 

To be Continue.......

Querying CosmosDB. Part 2

We will continue to play a little with the same JSON Example in Part 1
We will try to do queries a little more complicated.

Total amount of time (in minutes) of laboratory in particular event.

SELECT VALUE SUM(act.duration) FROM c
JOIN act IN c.activities
WHERE act.type=”lab” AND c.event_name= “CosmosDB Conf”


List activities from specific type and from specific event

JOIN act IN c.activities
WHERE act.type=”conference” AND c.event_name= “CosmosDB Conf”


Get activities where duration is more than 30 minutes

SELECT VALUE act FROM c JOIN act IN c.activities
WHERE act.duration>30


Same as previous but bring me more information for each document

“activity”:act} FROM c
JOIN act IN c.activities
WHERE act.duration>30 and act.type=”lab”


In case you have more complex JSON Document let us know. I’d like to help and be involve in…

Querying CosmosDB. Part 1

Hi CosmosDB Community !!!
I'd like to contribute with some posts about how to query Cosmos DB Collection with SQL API.

Suppose we have a speaker list of differents events around a whole world.

The link above represent speaker list example.

For all examples we will use Data Explore in Azure Portal. Anyway, you can use any API in any supported programming language to write your queries. We are not using Modeling data techniques or witting same data in different ways to avoid cross partition queries. The main objective of the post is how to use built-in functions and operators in CosmosDB SQL API.

I'd like to list all events from Hassan Arteaga Rodríguez 
SELECT * FROM c where c.speaker = "Hassan Arteaga Rodriguez"

I need to list all events from MEXICO. Not all fields Query
SELECT c.speaker, c.event_name,c.init_date,c.end_date FROM c where c.event_country = "MEXICO"

I'd like to list all events  in June Query


Message Queue + Azure Functions + CosmosDB. A perfect trio !!!

Ok !! It's not about SEX, it's about something they name AZURE.

Seriously, I'll asume in this short article, that you have some kind of experience with azure.

Suppose you have a heavy load. Incoming data come from some entity(application) that send, with high frequency, messages to some queue in Azure. Also you need analyze incoming data and apply some logic before insert data in your persistence layer.

It's a complicated task ?

Actually it's a simple task !!!
Step  1. Create storage account. 

Step 2. Create Queue

Step 3.  CosmosDB Resource

Let's asume we already have Data Base and Collection "READY" in CosmosDB

Step 4. Create Azure Function Application

Step 5 Create Azure Function. 

In this step we will see how to bind Message Queue and  CosmosDB collection inside Azure Function.

We will use template for Queue Trigger.

Define name and input bind. Remember this Azure function will listen a queue for message incoming.
Select storage account to create conne…

Awesome !!!

Beautiful way to search information....visit

Update data in COSMOS DB with Azure Functions.

I was looking for a way to update COSMOS DB document after receive a  request inside Azure Function without any COSMOS DB biding.

I didn't find a way !!
 I took another way. I don't know if it is the right or wrong way. But this way works for me.

Scenario is very simple. We have sales orders arriving into the data base. We have another Azure function to insert those new orders. But suppose we need to cancel some order. How to do that using Azure Function ?

Let´s start !!!
Step 1. Sample Collection. This collection is very simple,  we are focused on results.

Step 2. Create a Function and Select HttpTrigger template. 

Step 3. Code 

More code. 

Step 4. Test

Step 5. Results 

See you soon