Add Azure Cosmos DB for MongoDB trigger, input, and output bindings#418
Add Azure Cosmos DB for MongoDB trigger, input, and output bindings#418xingfan-git wants to merge 10 commits into
Conversation
|
@xingfan-git do you have a sample app, which would help me validate the changes? |
swapnil-nagar
left a comment
There was a problem hiding this comment.
Sample app to validate this change
|
@swapnil-nagar I have added sample code in this repo. If you need a connection string, please let me know |
…/github.com/Azure/azure-functions-nodejs-library into xingfan/onboarding_mongodb_extension_nodejs
There was a problem hiding this comment.
Pull request overview
This PR adds first-class Node.js programming model support for Azure Cosmos DB for MongoDB bindings, including a new trigger plus input/output binding factories and a sample app.
Changes:
- Adds
cosmosDBMongotrigger/input/output factories andapp.cosmosDBMongo()registration support. - Introduces public TypeScript types for Cosmos DB Mongo trigger/input/output options and handler signatures.
- Adds unit tests and a new end-to-end-ish sample project demonstrating usage.
Reviewed changes
Copilot reviewed 14 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| types/trigger.d.ts | Exposes trigger.cosmosDBMongo() in public typings. |
| types/input.d.ts | Exposes input.cosmosDBMongo() in public typings. |
| types/output.d.ts | Exposes output.cosmosDBMongo() in public typings. |
| types/app.d.ts | Exposes app.cosmosDBMongo() registration signature. |
| types/index.d.ts | Re-exports new Cosmos DB Mongo types. |
| types/cosmosDBMongo.d.ts | Adds new public option/handler/binding type definitions. |
| src/trigger.ts | Implements trigger.cosmosDBMongo() factory with deterministic binding naming. |
| src/input.ts | Implements input.cosmosDBMongo() factory with deterministic binding naming. |
| src/output.ts | Implements output.cosmosDBMongo() factory with deterministic binding naming. |
| src/app.ts | Implements app.cosmosDBMongo() registration via generic registration path. |
| test/cosmosDBMongo.test.ts | Adds unit tests validating type strings, option copying, name determinism, and binding directions. |
| sample/cosmosDBMongo/* | Adds a runnable sample showcasing trigger + HTTP read/write via input/output bindings. |
Files not reviewed (1)
- sample/cosmosDBMongo/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Also, as explained this changes will be in preview, hence lets make changes in the package.json with version 4.15.0-preview |
|
PR for e2e test: Azure/azure-functions-nodejs-e2e-tests#88 |
Yes, but that would be a task that you will need after this PR goes through. |
|
@swapnil-nagar I've updated the version to 4.16-preview as current version in v4.x is already 4.15, if it's not correct, please let me know. |
Summary
This PR adds Node.js SDK support for the Azure Cosmos DB for MongoDB bindings, enabling
developers to trigger functions on MongoDB change stream events and read/write documents
from MongoDB collections using the Azure Functions programming model.
Changes
New Features
app.cosmosDBMongo()— New function registration method for Cosmos DB for MongoDBtriggered functions
trigger.cosmosDBMongo()— New trigger factory for monitoring MongoDB change streams(supports Collection / Database / Cluster level)
input.cosmosDBMongo()— New input binding factory for reading documents from a MongoDBcollection, with optional
queryStringfilter supportoutput.cosmosDBMongo()— New output binding factory for upserting documents into aMongoDB collection
CosmosDBMongoTriggerOptions,CosmosDBMongoTrigger,CosmosDBMongoFunctionOptions,CosmosDBMongoHandler,CosmosDBMongoInputOptions,CosmosDBMongoInput,CosmosDBMongoOutputOptions, andCosmosDBMongoOutputBinding Type Strings
cosmosDBMongoTriggercosmosDBMongocosmosDBMongoTests
Added
test/cosmosDBMongo.test.tswith 12 test cases covering trigger, input, and output —verifying type strings, all binding options, deterministic binding name generation, and
correct
directionvalues viatoCoreFunctionMetadata.