CosmosDBOutput Interface
Implements
public interface CosmosDBOutput
implements java.lang.annotation.Annotation
Place this on a parameter whose value would be written to CosmosDB. The parameter type should be OutputBinding, where T could be one of:
- Some native Java types such as String
- Any POJO type
The following example shows a Java function that adds a document to a database, using data provided in the body of an HTTP Post request.
@FunctionName("addItem")
public String cosmosDbAddItem(
@HttpTrigger(name = "request", methods = {HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS)
final String message,
@CosmosDBOutput(name = "database", databaseName = "ToDoList", collectionName = "Items",
connectionStringSetting = "AzureCosmosDBConnection")
) {
return "{ \"id\": \"" + System.currentTimeMillis() + "\", \"description\": \"" + message + "\" }";
}
Modifier and Type | Method and Description |
---|---|
abstract java.lang.String |
collection Defines the collection name of the CosmosDB to which to write. |
abstract int |
collection If Create |
abstract java.lang.String |
connection Defines the app setting name that contains the CosmosDB connection string. |
abstract boolean |
create Defines the ID of the CosmosDB to which to write. |
abstract java.lang.String |
data Defines how Functions runtime should treat the parameter value. |
abstract java.lang.String |
database Defines the database name of the CosmosDB to which to write. |
abstract java.lang.String |
name()
The variable name used in function. |
abstract java.lang.String |
partition Defines the partition key path for the created collection when create |
abstract java.lang.String |
preferred Defines preferred locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service. |
abstract boolean |
use Enable to use with Multi Master accounts. |
collectionName
public abstract String collectionName()
Defines the collection name of the CosmosDB to which to write.
Returns:
collectionThroughput
public abstract int collectionThroughput()
If CreateIfNotExists is true, defines the throughput of the created collection.
Returns:
connectionStringSetting
public abstract String connectionStringSetting()
Defines the app setting name that contains the CosmosDB connection string.
Returns:
createIfNotExists
public abstract boolean createIfNotExists()
Defines the ID of the CosmosDB to which to write.
Returns:
dataType
public abstract String dataType()
Defines how Functions runtime should treat the parameter value. Possible values are:
- "" or string: treat it as a string whose value is serialized from the parameter
- binary: treat it as a binary data whose value comes from for example OutputBinding<byte[]>
Returns:
databaseName
public abstract String databaseName()
Defines the database name of the CosmosDB to which to write.
Returns:
name
public abstract String name()
The variable name used in function.json.
Returns:
partitionKey
public abstract String partitionKey()
Defines the partition key path for the created collection when createIfNotExists is set to true. May include binding parameters.
Returns:
preferredLocations
public abstract 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:
useMultipleWriteLocations
public abstract boolean useMultipleWriteLocations()
Enable to use with Multi Master accounts.
Returns:
Azure SDK for Java feedback
Azure SDK for Java is an open source project. Select a link to provide feedback: