@Retention(value=RUNTIME) @Target(value=PARAMETER) public @interface CosmosDBTrigger
Place this on a parameter whose value would come from CosmosDB, and causing the method to run when CosmosDB data is changed. The parameter type can be one of the following:
The following example shows a Java function that is invoked when there are inserts or updates in the specified database and collection.
@FunctionName("cosmosDBMonitor")
public void cosmosDbLog(
@CosmosDBTrigger(name = "database",
databaseName = "ToDoList",
collectionName = "Items",
leaseCollectionName = "leases",
createLeaseCollectionIfNotExists = true,
connectionStringSetting = "AzureCosmosDBConnection")
List<Map<String, String>> items,
final ExecutionContext context
) {
context.getLogger().info(items.size() + " item(s) is/are inserted.");
if (!items.isEmpty()) {
context.getLogger().info("The ID of the first item is: " + items.get(0).get("id"));
}
}
| Modifier and Type | Required Element and Description |
|---|---|
String |
collectionName
Defines the collection name of the CosmosDB to which to bind.
|
String |
connectionStringSetting
Defines the app setting name that contains the CosmosDB connection string.
|
String |
databaseName
Defines the database name of the CosmosDB to which to bind.
|
String |
name
The variable name used in function.json.
|
| Modifier and Type | Optional Element and Description |
|---|---|
int |
checkpointDocumentCount
Customizes the amount of documents between lease checkpoints.
|
int |
checkpointInterval
Customizes the amount of milliseconds between lease checkpoints.
|
boolean |
createLeaseCollectionIfNotExists
Defines whether to create a new lease collection if not exists.
|
String |
dataType
Defines how Functions runtime should treat the parameter value.
|
int |
feedPollDelay
Customizes the delay in milliseconds in between polling a partition for new changes on the
feed, after all current changes are drained.
|
int |
leaseAcquireInterval
Customizes the interval in milliseconds to kick off a task to compute if partitions are
distributed evenly among known host instances.
|
String |
leaseCollectionName
Defines the lease collection name of the CosmosDB to which to bind.
|
String |
leaseCollectionPrefix
Defines a prefix to be used within a Leases collection for this Trigger.
|
String |
leaseConnectionStringSetting
Defines Connection string for the service containing the lease collection.
|
String |
leaseDatabaseName
Defines Name of the database containing the lease collection.
|
int |
leaseExpirationInterval
Customizes the interval in milliseconds for which the lease is taken on a lease representing a
partition.
|
int |
leaseRenewInterval
Customizes the renew interval in milliseconds for all leases for partitions currently held by
the Trigger.
|
int |
leasesCollectionThroughput
defines the throughput of the created collection..
|
int |
maxItemsPerInvocation
Customizes the maximum amount of items received in an invocation
|
String |
preferredLocations
Defines preferred locations (regions) for geo-replicated database accounts in the Azure Cosmos
DB service.
|
boolean |
startFromBeginning
Gets or sets whether change feed in the Azure Cosmos DB service should start from beginning
(true) or from current (false).
|
public abstract String name
public abstract String databaseName
public abstract String collectionName
public abstract String connectionStringSetting
public abstract String dataType
Defines how Functions runtime should treat the parameter value. Possible values are:
public abstract String leaseConnectionStringSetting
public abstract String leaseCollectionName
public abstract String leaseDatabaseName
public abstract boolean createLeaseCollectionIfNotExists
public abstract int leasesCollectionThroughput
public abstract String leaseCollectionPrefix
public abstract int checkpointInterval
public abstract int checkpointDocumentCount
public abstract int feedPollDelay
public abstract int leaseRenewInterval
public abstract int leaseAcquireInterval
public abstract int leaseExpirationInterval
public abstract int maxItemsPerInvocation
public abstract boolean startFromBeginning
public abstract String preferredLocations
Copyright © 2022. All rights reserved.