in azure/functions/decorators/function_app.py [0:0]
def cosmos_db_trigger_v3(self,
arg_name: str,
database_name: str,
collection_name: str,
connection_string_setting: str,
lease_collection_name: Optional[str] = None,
lease_connection_string_setting: Optional[
str] = None,
lease_database_name: Optional[str] = None,
create_lease_collection_if_not_exists: Optional[
bool] = None,
leases_collection_throughput: Optional[int] =
None,
lease_collection_prefix: Optional[str] = None,
checkpoint_interval: Optional[int] = None,
checkpoint_document_count: Optional[int] = None,
feed_poll_delay: Optional[int] = None,
lease_renew_interval: Optional[int] = None,
lease_acquire_interval: Optional[int] = None,
lease_expiration_interval: Optional[int] = None,
max_items_per_invocation: Optional[int] = None,
start_from_beginning: Optional[bool] = None,
preferred_locations: Optional[str] = None,
data_type: Optional[
Union[DataType, str]] = None,
**kwargs: Any) -> \
Callable[..., Any]:
"""The cosmos_db_trigger_v3 decorator adds :class:`CosmosDBTrigger`
to the :class:`FunctionBuilder` object
for building :class:`Function` object used in worker function
indexing model. This decorator will work only with extension bundle 2.x
or 3.x. For additional details, please refer
https://aka.ms/cosmosdb-v4-update.
This is equivalent to defining CosmosDBTrigger in the function.json
which enables function to be triggered when CosmosDB data is changed.
All optional fields will be given default value by function host when
they are parsed by function host.
Ref: https://aka.ms/azure-function-binding-cosmosdb-v2
:param arg_name: The name of the variable that represents
:class:`DocumentList` object in function code.
:param database_name: The name of the Azure Cosmos DB database with
the collection being monitored.
:param collection_name: The name of the collection being monitored.
:param connection_string_setting: The name of an app setting or
setting collection that specifies how to connect to the Azure Cosmos
DB account being monitored.
:param lease_collection_name: The name of the collection used to
store leases.
:param lease_connection_string_setting: The name of an app setting
or setting collection that specifies how to connect to the Azure
Cosmos DB account that holds the lease collection.
:param lease_database_name: The name of the database that holds the
collection used to store leases.
:param create_lease_collection_if_not_exists: When set to true,
the leases collection is automatically created when it doesn't
already exist.
:param leases_collection_throughput: Defines the number of Request
Units to assign when the leases collection is created.
:param lease_collection_prefix: When set, the value is added as a
prefix to the leases created in the Lease collection for this
Function.
:param checkpoint_interval: When set, it defines, in milliseconds,
the interval between lease checkpoints. Default is always after a
Function call.
:param checkpoint_document_count: Customizes the amount of documents
between lease checkpoints. Default is always after a Function call.
:param feed_poll_delay: The time (in milliseconds) for the delay
between polling a partition for new changes on the feed, after all
current changes are drained.
:param lease_renew_interval: When set, it defines, in milliseconds,
the renew interval for all leases for partitions currently held by
an instance.
:param lease_acquire_interval: When set, it defines,
in milliseconds, the interval to kick off a task to compute if
partitions are distributed evenly among known host instances.
:param lease_expiration_interval: When set, it defines,
in milliseconds, the interval for which the lease is taken on a
lease representing a partition.
:param max_items_per_invocation: When set, this property sets the
maximum number of items received per Function call.
:param start_from_beginning: This option tells the Trigger to read
changes from the beginning of the collection's change history
instead of starting at the current time.
:param preferred_locations: Defines preferred locations (regions)
for geo-replicated database accounts in the Azure Cosmos DB service.
:param data_type: Defines how Functions runtime should treat the
parameter value.
:param kwargs: Keyword arguments for specifying additional binding
fields to include in the binding json.
:return: Decorator function.
"""
trigger = CosmosDBTriggerV3(
name=arg_name,
database_name=database_name,
collection_name=collection_name,
connection_string_setting=connection_string_setting,
lease_collection_name=lease_collection_name,
lease_connection_string_setting=lease_connection_string_setting,
lease_database_name=lease_database_name,
create_lease_collection_if_not_exists=create_lease_collection_if_not_exists, # NoQA
leases_collection_throughput=leases_collection_throughput,
lease_collection_prefix=lease_collection_prefix,
checkpoint_interval=checkpoint_interval,
checkpoint_document_count=checkpoint_document_count,
feed_poll_delay=feed_poll_delay,
lease_renew_interval=lease_renew_interval,
lease_acquire_interval=lease_acquire_interval,
lease_expiration_interval=lease_expiration_interval,
max_items_per_invocation=max_items_per_invocation,
start_from_beginning=start_from_beginning,
preferred_locations=preferred_locations,
data_type=parse_singular_param_to_enum(data_type, DataType),
**kwargs)
@self._configure_function_builder
def wrap(fb):
def decorator():
fb.add_trigger(trigger=trigger)
return fb
return decorator()
return wrap