0

We are developing applications using azure functions (python). I have 2 questions regarding Azure Functions Application

  1. Can we monitor 2 collections using single Cosmosdb trigger ? --- I have looked through the documentation and it seems it doesn't support. Did i miss anything ?

  2. If there are 2 functions monitoring the same collection, will only one of the functions be triggered. -- I observed this behaviour today. I was running 2 instances of functions app and the data from cosmosdb trigger was sent to only one of the application. I am trying to find out the reason for it.

SunilS
  • 2,030
  • 5
  • 34
  • 62

1 Answers1

0

EDIT: 1-I had never used multiple input triggers, but according to the official wiki it's possible, just add function.json file:

{
  "bindings": [
    {
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "image-resize"
    },
    {
      "type": "blob",
      "name": "original",
      "direction": "in",
      "path": "images-original/{name}"
    },
    {
      "type": "blob",
      "name": "resized",
      "direction": "out",
      "path": "images-resized/{name}"
    }
  ]
}

PS: I know you're using cosmosDB, the sample above is just to illustrate

2- I assume it's due the way it's implemented (e.g topic vs queue). So the first function lock the event / message, then the second one is not aware of the event. At this moment, Durable Functions for python is still under development and should be released next month (03/2020). It will allow you to chain the execution of the functions just like it's available for c# / node:

https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#chaining

What you can do is output to a queue, which will trigger your second function after the first function completes. (pretty much what Durable Functions offers)

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90
  • As per the documentation, https://learn.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings. A trigger defines how a function is invoked and a function must have exactly one trigger. Triggers have associated data, which is often provided as the payload of the function. So, the above example may not work ? – SunilS Feb 27 '20 at 16:34
  • I've also got the json sample from official doc and as you can see, it has two input triggers – Thiago Custodio Feb 27 '20 at 17:07