Implements
java.lang.annotation.Annotation
public interface CosmosDBInput
implements java.lang.annotation.Annotation
Place this on a parameter whose value would come from CosmosDB. The parameter type can be one of the following:
The following example shows a Java function that retrieves a single document. The function is triggered by an HTTP request that uses a query string to specify the ID to look up. That ID is used to retrieve a ToDoItem document from the specified database and collection. A sample URL would be like: http://localhost:7071/api/getItem?id=myid.
@FunctionName("getItem")
public String cosmosDbQueryById(
@HttpTrigger(name = "req",
methods = {HttpMethod.GET},
authLevel = AuthorizationLevel.ANONYMOUS) Optional<String> dummy,
@CosmosDBInput(name = "database",
databaseName = "ToDoList",
collectionName = "Items",
id = "{Query.id}",
connectionStringSetting = "AzureCosmosDBConnection") Optional<String> item
) {
return item.orElse("Not found");
}
Method Summary Modifier and Type Method and Description abstract java.lang.String collectionName()
Defines the collection name of the CosmosDB to which to bind.
abstract java.lang.String connectionStringSetting()Defines the app setting name that contains the CosmosDB connection string.
abstract java.lang.String databaseName()Defines the database name of the CosmosDB to which to bind.
abstract java.lang.String dataType()Defines how Functions runtime should treat the parameter value.
abstract java.lang.String id()Defines the ID of the CosmosDB to which to bind.
abstract java.lang.String name()The variable name used in function.json.
abstract java.lang.String partitionKey()Defines partition key value for the lookup.
abstract java.lang.String sqlQuery()Defines the SQL query string to which to bind.
Method Details collectionNamepublic abstract String collectionName()
Defines the collection name of the CosmosDB to which to bind.
Returns:
The collection name string.
connectionStringSettingpublic abstract String connectionStringSetting()
Defines the app setting name that contains the CosmosDB connection string.
Returns:
The app setting name of the connection string.
databaseNamepublic abstract String databaseName()
Defines the database name of the CosmosDB to which to bind.
Returns:
The database name string.
dataTypepublic abstract String dataType()
Defines how Functions runtime should treat the parameter value. Possible values are:
Returns:
The dataType which will be used by the Functions runtime.
idpublic abstract String id()
Defines the ID of the CosmosDB to which to bind.
Returns:
The ID string.
namepublic abstract String name()
The variable name used in function.json.
Returns:
The variable name used in function.json.
partitionKeypublic abstract String partitionKey()
Defines partition key value for the lookup. May include binding parameters.
Returns:
partition key value
sqlQuerypublic abstract String sqlQuery()
Defines the SQL query string to which to bind.
Returns:
The SQL query string.
Applies toCollaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4