none
Azure function cosmos db RRS feed

  • Question

  • i am trying to add Cosmos db trigger from visual studio 2017 but not able to add because it is not present in Azure Function while other triggers are present

    Team please let me know whether it is deprecated or i need to add some plugin for Cosmos Trigger .

    Monday, April 9, 2018 1:24 PM

Answers

  • Hope you have installed Azure Functions and Web Jobs Tools.

    With this tooling, when we create an Azure Functions project, we are asked to choose the version V1 or V2.

    Number of templates supported in V1 and V2 is different from each other. In other words, Cosmos DB Trigger template is only included in V1. On the other hand, there is no template for Cosmos DB Trigger in V2 at the time of this writing 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (kokkisajee) or Facebook (sajeetharan) profile for Sajeetharan at Stack Overflow, Q&A for professional and enthusiast programmers

    • Proposed as answer by David Ebbo Monday, April 9, 2018 3:25 PM
    • Marked as answer by Navdep Tuesday, April 10, 2018 7:26 AM
    Monday, April 9, 2018 1:38 PM

All replies

  • Hope you have installed Azure Functions and Web Jobs Tools.

    With this tooling, when we create an Azure Functions project, we are asked to choose the version V1 or V2.

    Number of templates supported in V1 and V2 is different from each other. In other words, Cosmos DB Trigger template is only included in V1. On the other hand, there is no template for Cosmos DB Trigger in V2 at the time of this writing 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (kokkisajee) or Facebook (sajeetharan) profile for Sajeetharan at Stack Overflow, Q&A for professional and enthusiast programmers

    • Proposed as answer by David Ebbo Monday, April 9, 2018 3:25 PM
    • Marked as answer by Navdep Tuesday, April 10, 2018 7:26 AM
    Monday, April 9, 2018 1:38 PM
  • Thanks for the reply.

    Is there any way through we can implement "Cosmos DB Trigger" in V2 of Visual studio 2107.

    Tuesday, April 10, 2018 6:38 AM
  • Yes, there is a way to implement 'Azure Cosmos DB trigger' in Azure Functions V2.
    This doc has all the information on Trigger attributes and configurations.
    Below is an example to achieve this in C#:

    using System.Collections.Generic;
        using Microsoft.Azure.Documents;
        using Microsoft.Azure.WebJobs;
        using Microsoft.Azure.WebJobs.Host;
    
        [FunctionName("DocumentUpdates")]
        public static void Run(
            [CosmosDBTrigger("database", "collection", ConnectionStringSetting = "myCosmosDB")]
        IReadOnlyList<Document> documents,
            TraceWriter log)
        {
                log.Info("Documents modified " + documents.Count);
                log.Info("First document Id " + documents[0].Id);
        }

    Wednesday, April 11, 2018 4:58 AM
    Moderator
  • I tried , but "Microsoft.Azure.WebJobs.Extensions" is not compatible with V2.
    Wednesday, April 11, 2018 8:25 AM