Annotation Type CosmosDBTrigger
-
@Retention(RUNTIME) @Target(PARAMETER) public @interface CosmosDBTriggerPlace 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:
- Some native Java types such as String
- Nullable values using Optional<T>
- Any POJO type
The following example shows a Java function that is invoked when there are inserts or updates in the specified database and container.
@FunctionName("cosmosDBMonitor") public void cosmosDbLog( @CosmosDBTrigger(name = "database", databaseName = "ToDoList", containerName = "Items", leaseContainerName = "leases", createLeaseContainerIfNotExists = true, connection = "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")); } }- Since:
- 1.0.0
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.StringconnectionDefines the app setting name that contains the CosmosDB connection string.java.lang.StringcontainerNameDefines the container name of the CosmosDB to which to bind.java.lang.StringdatabaseNameDefines the database name of the CosmosDB to which to bind.java.lang.StringnameThe variable name used in function.json.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description intcheckpointDocumentCountCustomizes the amount of documents between lease checkpoints.intcheckpointIntervalCustomizes the amount of milliseconds between lease checkpoints.booleancreateLeaseContainerIfNotExistsDefines whether to create a new lease container if not exists.java.lang.StringdataTypeDefines how Functions runtime should treat the parameter value.intfeedPollDelayCustomizes the delay in milliseconds in between polling a partition for new changes on the feed, after all current changes are drained.intleaseAcquireIntervalCustomizes the interval in milliseconds to kick off a task to compute if partitions are distributed evenly among known host instances.java.lang.StringleaseConnectionStringSettingDefines Connection string for the service containing the lease container.java.lang.StringleaseContainerNameDefines the lease container name of the CosmosDB to which to bind.java.lang.StringleaseContainerPrefixDefines a prefix to be used within a Leases container for this Trigger.java.lang.StringleaseDatabaseNameDefines Name of the database containing the lease container.intleaseExpirationIntervalCustomizes the interval in milliseconds for which the lease is taken on a lease representing a partition.intleaseRenewIntervalCustomizes the renew interval in milliseconds for all leases for partitions currently held by the Trigger.intleasesContainerThroughputdefines the throughput of the created container.intmaxItemsPerInvocationCustomizes the maximum amount of items received in an invocationjava.lang.StringpreferredLocationsDefines preferred locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.booleanstartFromBeginningGets or sets whether change feed in the Azure Cosmos DB service should start from beginning (true) or from current (false).
-
-
-
-
dataType
java.lang.String dataType
Defines how Functions runtime should treat the parameter value. Possible values are:
- "": get the value as a string, and try to deserialize to actual parameter type like POJO
- string: always get the value as a string
- binary: get the value as a binary data, and try to deserialize to actual parameter type byte[]
- Returns:
- The dataType which will be used by the Functions runtime.
- Default:
- ""
-
-
-
leaseExpirationInterval
int leaseExpirationInterval
Customizes the interval in milliseconds for which the lease is taken on a lease representing a partition. If the lease is not renewed within this interval, it will cause it to expire and ownership of the partition will move to another Trigger instance. Default is 60000 (60 seconds).- Returns:
- interval in milliseconds for which the lease is taken
- Default:
- 60000
-
-
-
preferredLocations
java.lang.String preferredLocations
Defines preferred locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service. Values should be comma-separated. example, PreferredLocations = "East US,South Central US,North Europe"- Returns:
- preferred locations (regions) for geo-replicated database accounts
- Default:
- ""
-
-