Annotation Type CosmosDBOutput
-
@Retention(RUNTIME) @Target({PARAMETER,METHOD}) public @interface CosmosDBOutputPlace this on a parameter whose value would be written to CosmosDB. The parameter type should be OutputBinding<T>, 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", containerName = "Items", connection = "AzureCosmosDBConnection") ) { return "{ \"id\": \"" + System.currentTimeMillis() + "\", \"description\": \"" + message + "\" }"; }- 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 write.java.lang.StringdatabaseNameDefines the database name of the CosmosDB to which to write.java.lang.StringnameThe variable name used in function.json.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description intcontainerThroughputIf CreateIfNotExists is true, defines the throughput of the created container.booleancreateIfNotExistsDefines the ID of the CosmosDB to which to write.java.lang.StringdataTypeDefines how Functions runtime should treat the parameter value.java.lang.StringpartitionKeyDefines the partition key path for the created container when createIfNotExists is set to true.java.lang.StringpreferredLocationsDefines preferred locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.booleanuseMultipleWriteLocationsEnable to use with Multi Master accounts.
-
-
-
-
dataType
java.lang.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:
- The dataType which will be used by the Functions runtime.
- Default:
- ""
-
-
-
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:
- PreferredLocations for geo-replicated database accounts
- Default:
- ""
-
-