Add an Azure Cosmos DB trigger to an existing Azure Function app from Azure Cosmos DB Portal

By | February 9, 2018

Add Azure Function from Azure Cosmos DB

Azure Functions let us execute our code in a serverless environment. This does not require create a solution or publish it as Azure Apps. In short, just focus on code and your functional aspect, and don’t need to worry about infrastructure. We can create a function triggered when data is added to or changed in Azure Cosmos DB and further we can take it for processing using the Azure Function.

We follow the below steps to create a Function trigger for Azure Cosmos DB
1. Create a new Azure Function App
2. Create Azure Cosmos DB trigger
3. Setup the Cosmos DB Trigger with required details.

Azure Cosmos DB Trigger for Azure Function

Azure Cosmos DB Trigger for Azure Function

Must Read : 

5 simple steps to create and test your first Azure Function App

Well, on the other hand, you can Add an Azure Cosmos DB trigger to an existing Azure Function app from Azure Cosmos DB Portal itself.

To achieve that, Open the Cosmos DB Resource in the Azure Portal and select “Add Azure Function” from the Settings section.

 

 

Add Azure Function from Azure Cosmos DB

Add Azure Function from Azure Cosmos DB

In the “Add Azure Function” dialog, select the collection and an existing Azure Function for which you want to add the trigger.

 

Add Azure Function and Save

Add Azure Function and Save

Click on “Save

In this case, you must ensure your Azure Function app is in the same resource group of your Azure Cosmos DB.

 

That’s it. Once trigger creation and update are complete, you will be redirected to the Azure Function for which you added the trigger.

Added Cosmos DB Trigger for Azure Function

Added Cosmos DB Trigger for Azure Function

 

You can then further update your Azure function from here.
Hope this helps.

Author: Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

2 thoughts on “Add an Azure Cosmos DB trigger to an existing Azure Function app from Azure Cosmos DB Portal

  1. Pingback: Dew Drop - February 9, 2018 (#2662) - Morning Dew

  2. Pingback: Azure Weekly: Feb 12, 2018 – Build Azure

Leave a Reply