Trigger Configuration Files
Note
This page describes a legacy configuration file format. You should
only use this information if you're using the deprecated
realm-cli
.
Any configuration files you pull with App Services CLI or export from the UI use the latest configuration version. For detailed information on the current configuration file format, see App Configuration.
app/ └── triggers/ └── <trigger name>.json
General Configuration
All triggers conform to a base schema with specific variations depending on the trigger type. The following fields exist in all trigger configuration files:
{ "name": "<Trigger Name>", "type": "<Trigger Type>", "config": {}, "function_name": "<Trigger Function Name>", "disabled": <Boolean> }
Field | Description |
---|---|
name String | The trigger name. This may be at most 64 characters
long and can only contain ASCII letters, numbers, underscores,
and hyphens. |
type String | The trigger type. The value of this field determines the exact configuration file schema. Valid Options:
|
config Document | A document with fields that map to additional configuration options for
the trigger. The exact configuration fields depend on the trigger
|
function_name String | The name of the Atlas Function that the
trigger executes whenever it fires. |
event_processors Document | A document that configures the trigger to send events to external event
processors whenever it fires. Cannot be used with For more information, see Send Trigger Events to AWS EventBridge. |
disabled Boolean | If true , the trigger will not listen for any events and will
not fire. |
Database Triggers
Database trigger configurations conform to the base trigger schema with additional configuration options that specify which collection to watch and when to fire the trigger. The following fields exist in database trigger configuration files:
{ "name": "<Trigger Name>", "type": "DATABASE", "config": { "service_name": "<MongoDB Service Name>", "database": "<Database Name>", "collection": "<Collection Name>", "operation_types": ["<Operation Type>", ...], "full_document": <boolean>, "full_document_before_change": <boolean>, "tolerate_resume_errors": <boolean>, "unordered": <boolean>, "match": { <Match Filter> }, "project": { <Projection Filter> }, }, "function_name": "<Trigger Function Name>", "disabled": <Boolean> }
Field | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
config.service_name String | The name of the MongoDB data source
that contains the watched collection. You cannot define a database
trigger on a serverless instance or
Federated database instance. | ||||||||
config.database String | The name of the MongoDB database that contains the watched collection. | ||||||||
config.collection String | The name of the collection that the trigger watches. | ||||||||
config.operation_types String[] | A list of one or more database operation types that cause the trigger to fire. Valid operations types:
TipUpdate operations executed from MongoDB Compass or the MongoDB Atlas Data
Explorer fully replace the previous document. As a result, update
operations from these clients will generate | ||||||||
config.full_document Boolean | If NoteRegardless of this setting:
| ||||||||
config.full_document_before_change Boolean | If ImportantCollection-Level Preimage SettingsDocument preimages use extra information stored in the oplog. The extra data may have performance implications for some apps. Once you've enabled document preimages for any trigger on a given collection, that collection will include preimage data in the oplog and other triggers on the collection can use preimages with no additonal overhead. You can disable document preimages on a per-trigger basis to exclude the preimage from change events. Regardless of your trigger-level settings, a collection's oplog entries will continue to include preimage data unless you explicitly disable preimages for the collection. For more information, see Document Preimages. | ||||||||
config.tolerate_resume_errors Boolean | If If enabled, when this Trigger's resume token cannot be found in the cluster's oplog, the Trigger automatically resumes processing events at the next relevant change stream event. All change stream events from when the Trigger was suspended until the Trigger resumes execution do not have the Trigger fire for them. For more information on resuming suspended Triggers, see Suspended Triggers. | ||||||||
config.unordered Boolean | If If event ordering is enabled, multiple executions of this Trigger will occur sequentially based on the timestamps of the change events. If event ordering is disabled, multiple executions of this Trigger will occur independently. TipPerformance OptimizationImprove performance for Triggers that respond to bulk database operations by disabling event ordering. Learn more. | ||||||||
config.match Document | A $match expression document
that App Services uses to filter which change events cause the Trigger to
fire. The Trigger evaluates all change event objects that it receives against
this match expression and only executes if the expression evaluates to NoteUse Dot-Notation for Embedded FieldsMongoDB performs a full equality match for embedded documents in a match expression. If you want to match a specific field in an embedded document, refer to the field directly using dot-notation. For more information, see Query on Embedded Documents in the MongoDB server manual. TipPerformance OptimizationLimit the number of fields that the Trigger processes by using a $match expression. Learn more. | ||||||||
config.project Document | A $project expression that selects a subset of fields from each event in the change stream. You can use this to optimize the trigger's execution. The expression is an object that maps the name of fields in the change
event to either a
|
Authentication Triggers
Authentication trigger configurations conform to the base trigger schema with additional configuration options that specify which auth providers to watch and when to fire the trigger. The following fields exist in authentication trigger configuration files:
{ "name": "<Trigger Name>", "type": "AUTHENTICATION", "config": { "operation_type": ["<Operation Type>", ...], "providers": ["<Provider Type>", ...], }, "function_name": "<Trigger Function Name>", "disabled": <Boolean> }
Field | Description |
---|---|
config.operation_type String | The authentication operation type that causes the trigger to fire. Valid operations types:
|
config.providers String[] | A list of authentication provider types that the trigger watches. Valid provider types:
|
Scheduled Triggers
Scheduled trigger configurations conform to the base trigger schema with additional configuration options that specify the schedule on which the trigger fires. The following fields exist in scheduled trigger configuration files:
{ "name": "<Trigger Name>", "type": "SCHEDULED", "config": { "schedule": "<CRON expression>" }, "function_name": "<Trigger Function Name>", "disabled": <Boolean> }
Field | Description |
---|---|
config.schedule String | The CRON expression that
schedules the trigger's execution. |