Nick Josevski
Nick Josevski

Reputation: 4216

Can an Azure Function be triggered by the creation of a DocumentDB document?

If I have another Azure Function creating documents, based on some other event (e.g. API call).

Is there support (or will there be) to have an Azure Function run based on a new document being created?

using System;
public static void Run(object doc, TraceWriter log)
{
    log.Info($"doc based trigger? ... {doc}");
}

Binding I tried to use, i tried it with and wihout the "id" property, and type documentDB and documentDBTrigger :

"bindings": [
{
  "type": "documentDB",
  "name": "doc",
  "databaseName": "MyDb",
  "collectionName": "MyCollection",
  "connection": "mydb_DOCUMENTDB",
  "direction": "in"
}

Upvotes: 2

Views: 599

Answers (2)

mathewc
mathewc

Reputation: 13558

No, we don't currently have a DocumentDB trigger binding. Only input and output bindings.

The underlying DocumentDB support for Azure Functions lives in the azure-webjobs-sdk-extensions repo. Feel free to leave an issue in that repo for this feature request :)

Upvotes: 3

Thiago Custodio
Thiago Custodio

Reputation: 18387

I think you're searching for this: https://azure.microsoft.com/en-us/documentation/articles/functions-bindings-documentdb/

Another option: you can create a DocumentDB trigger that will put a message into a service bus Queue, and then, use a Service Bus binding for your Azure Function:

https://azure.microsoft.com/en-us/documentation/articles/functions-bindings-service-bus/

Upvotes: 0

Related Questions