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 ?
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 connection. Just click on new link to select from all storage accounts available in our Azure Subscription.
Step 6. OUTPUT Binding
Now we need create OUTPUT binding. In other words, we need create connection to CosmosDB to insert incoming data after analyze it.
Defining Data Base , collection, connection string and partition key in case you need it.
Step 7. Coding
I need to decouple a process. Then we use the queue capability to support high load. Many entities(applications), send simultaneously messages to a queue. There is a Azure Function listening message incoming , analyze it , apply logic and insert into cosmos db collection.
Step 8. Operation results
a.- Simulating an entity that sends a message to the queue.
You can use Microsoft Azure Storage Explorer
b.- Azure function log
c.- Query in CosmosDB collection
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 connection. Just click on new link to select from all storage accounts available in our Azure Subscription.
By default, we have this code.
Step 6. OUTPUT Binding
Now we need create OUTPUT binding. In other words, we need create connection to CosmosDB to insert incoming data after analyze it.
Defining Data Base , collection, connection string and partition key in case you need it.
Now magic is coming !!!
Step 7. Coding
Done ?Yes !!! I'll try to resume .
I need to decouple a process. Then we use the queue capability to support high load. Many entities(applications), send simultaneously messages to a queue. There is a Azure Function listening message incoming , analyze it , apply logic and insert into cosmos db collection.
Step 8. Operation results
a.- Simulating an entity that sends a message to the queue.
You can use Microsoft Azure Storage Explorer
b.- Azure function log
c.- Query in CosmosDB collection
Bye !!
Comments