Skip to main content

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 

Comments

Anonymous said…
We spent a lot of time, first of all trying to understad what is CosmosDb. Thank to you, our beloved friend, as usually, we learned a litle piece of all the "Cosmos" of software technologies.

Thanks for to be a god friend.

Raudel & lpguio
hahahahah u are amazing guys !!!!

Popular posts from this blog

Some architectures with Cosmos DB and Azure Functions

Fig 1. Access Control Fig 2. Documents storage with reference to blob. Fig 3. Automatic storage maintenance of Documents with expiration. Fig 4. Reports.

Add more security to an Azure CosmosDB Account.

W e can access programmatically to Azure Cosmos DB resources to create, query, and delete databases, document collections, and documents via REST API. To perform operations on Azure Cosmos DB resources, you can send HTTPS requests with a selected method: GET, POST, PUT, or DELETE to an CosmosDB endpoint.  Frequently we build architecture with centralized access to a persistence layer, then we won't let other applications access directly to this layer. Suppose we have the following hypothetical scenario (see Figure 1): Figure 1. Hypothetical Scenario Only WEB API Service with IP1 is allowed to establish connections with CosmosDB EndPoint. The others elements showed as Application are not allowed. By default we have in our CosmosDB resource the following configuration (see Figure 2) in Firewall and Virtual Networks option. Figure 2. Default Configuration To show you how this feature works, we are going to create a WEP API with a single function (r