0

I'd like to get an Azure Function working where the function gets triggered on every new item, modify of an existing item, or deletion of an item in the CosmosDB. The documentation i've been able to find so far is always about CosmosDB functioning as a documentDB.

However, I am using cosmosdb as a table storage for simple data. I've also found seperate documentation for Azure Table Storage which would trigger Azure Function, but i'm uncertain if that applies to CosmosDB also? To me it doesn't seem usable as it triggers on a queue message. https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-table-input?tabs=python

I currently have a function which puts data into the table using the python SDK. So there is not queue message to trigger off of.

Does anyone know how I create a function like this? A trigger on the control plane operation for the Table? So I can have the function look at the data in the table for that specific request.

Marco
  • 525
  • 4
  • 17

1 Answers1

0

I'd like to get an Azure Function working where the function gets triggered on every new item, modify of an existing item, or deletion of an item in the CosmosDB.

Azure function doesn't offer such a trigger to achieve what you want. You can design your own logic.

Such as:

1, Create a http trigger, call the http trigger after you finish the operations.

2, Create a queue trigger, send messages to queue trigger after you finish the operations.

Cindy Pau
  • 13,085
  • 1
  • 15
  • 27
  • 1
    You mean that I can use the http trigger from the initial azure function? sending the data I need to the http endpoint? – Marco Jun 08 '21 at 08:37
  • @Marco Yes, hit the http trigger endpoint by post request(with the information you need.). – Cindy Pau Jun 08 '21 at 08:40
  • @Marco There doesn't have a built-in trigger to achieve this. – Cindy Pau Jun 08 '21 at 08:41
  • Thanks Zhu :) i'll have a look into this. One thing that pops my mind is securing HTTP triggers. Can I make the HTTP trigger accessible ONLY to the other Function? I wouldn't want anything or anyone besides the initial Function to be able to access this http trigger.. Edit: I found this: https://learn.microsoft.com/en-us/azure/spring-cloud/tutorial-managed-identities-functions never mind. I'll do more research and looking around. Thanks for the insights – Marco Jun 08 '21 at 08:54
  • @Marco First, azure function http trigger has built-in key to protect the url. Second, you can use azure ad to protect the azure function. – Cindy Pau Jun 09 '21 at 01:38