All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.azure.functions.annotation.CosmosDBInput Maven / Gradle / Ivy

Go to download

This package contains all Java interfaces and annotations to interact with Microsoft Azure functions runtime.

The newest version!
/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 */

package com.microsoft.azure.functions.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 

* Place this on a parameter whose value would come from CosmosDB. The parameter * type can be one of the following: *

* *
    *
  • Some native Java types such as String
  • *
  • Nullable values using Optional<T>
  • *
  • Any POJO type
  • *
* * *

* 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 container. A sample URL would be like: * http://localhost:7071/api/getItem?id=myid. *

* *
 * {@literal @}FunctionName("getItem")
 * public String cosmosDbQueryById(
 *    {@literal @}HttpTrigger(name = "req",
 *                  methods = {HttpMethod.GET},
 *                  authLevel = AuthorizationLevel.ANONYMOUS) Optional<String> dummy,
 *    {@literal @}CosmosDBInput(name = "database",
 *                      databaseName = "ToDoList",
 *                      containerName = "Items",
 *                      id = "{Query.id}",
 *                      connection = "AzureCosmosDBConnection") Optional<String> item
 * ) {
 *     return item.orElse("Not found");
 * }
 * 
* * @since 1.0.0 */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) public @interface CosmosDBInput { /** * The variable name used in function.json. * * @return The variable name used in function.json. */ String name(); /** *

* Defines how Functions runtime should treat the parameter value. Possible * values are: *

*
    *
  • "": get the value as a string, and try to deserialize to actual parameter * type like POJO
  • *
  • string: always get the value as a string
  • *
  • binary: get the value as a binary data, and try to deserialize to actual * parameter type byte[]
  • *
* * @return The dataType which will be used by the Functions runtime. */ String dataType() default ""; /** * Defines the database name of the CosmosDB to which to bind. * * @return The database name string. */ String databaseName(); /** * Defines the container name of the CosmosDB to which to bind. * * @return The container name string. */ String containerName(); /** * Defines the ID of the CosmosDB to which to bind. * * @return The ID string. */ String id() default ""; /** * Defines the SQL query string to which to bind. * * @return The SQL query string. */ String sqlQuery() default ""; /** * Defines the app setting name that contains the CosmosDB connection string. * * @return The app setting name of the connection string. */ String connection(); /** * Defines partition key value for the lookup. May include binding parameters. * @return partition key value */ String partitionKey() default ""; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy