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 + "\" }";
}
Method Summary
Modifier and Type | Method and Description |
---|---|
abstract java.lang.String |
collectionName()
Defines the collection name of the CosmosDB to which to write. |
abstract int |
collectionThroughput()
If Create |
abstract java.lang.String |
connectionStringSetting()
Defines the app setting name that contains the CosmosDB connection string. |
abstract boolean |
createIfNotExists()
Defines the ID of the CosmosDB to which to write. |
abstract java.lang.String |
dataType()
Defines how Functions runtime should treat the parameter value. |
abstract java.lang.String |
databaseName()
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 |
partitionKey()
Defines the partition key path for the created collection when create |
abstract java.lang.String |
preferredLocations()
Defines preferred locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service. |
abstract boolean |
useMultipleWriteLocations()
Enable to use with Multi Master accounts. |
Method Details
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:
Applies to
Azure SDK for Java
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour