com.microsoft.azure.functions.annotation
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See License.txt in the project root for license information. Annotations and support classes for use as part of the Java API for Azure Functions.
Classes
BindingTest |
Unit tests that enforce annotation contracts and conventions for Functions |
Interfaces
BindingName |
Place this on a parameter whose value would come from Azure Functions runtime. Use this annotation when you want to get the value of trigger metadata, or when you defined your own bindings in function.json manually. |
BlobInput |
BlobInput(name = "file", dataType = "binary", path = "samples-workitems/{queueTrigger}") byte[] content, final ExecutionContext context ) { context.getLogger().info("The size of \"" + filename + "" is: " + content.length + " bytes"); } |
BlobOutput |
BlobInput(name = "source", path = "samples-workitems/{queueTrigger}") String content ) { return content; } |
BlobTrigger |
BindingName("name") String filename, final ExecutionContext context ) { context.getLogger().info("Name: " + filename + ", Size: " + content.length + " bytes"); } |
CosmosDBInput |
CosmosDBInput(name = "database", databaseName = "ToDoList", collectionName = "Items", id = "{Query.id}", connectionStringSetting = "AzureCosmosDBConnection") Optional<String> item ) { return item.orElse("Not found"); } |
CosmosDBOutput |
CosmosDBOutput(name = "database", databaseName = "ToDoList", collectionName = "Items", connectionStringSetting = "AzureCosmosDBConnection") ) { return "{ \"id": "" + System.currentTimeMillis() + "", "description": "" + message + "" }"; } |
CosmosDBTrigger |
CosmosDBTrigger(name = "database", databaseName = "ToDoList", collectionName = "Items", leaseCollectionName = "leases", createLeaseCollectionIfNotExists = true, connectionStringSetting = "AzureCosmosDBConnection") List<Map<String, String>> items, final ExecutionContext context ) { context.getLogger().info(items.size() + " item(s) is/are inserted."); if (!items.isEmpty()) { context.getLogger().info("The ID of the first item is: " + items.get(0).get("id")); } } |
CustomBinding |
CustomBinding(direction = "in", name = "inputParameterName", type = "customBindingTrigger") String customTriggerInput final ExecutionContext context ) { context.getLogger().info(customTriggerInput); } |
EventGridOutput |
EventGridOutput(name = "outputEvent", topicEndpointUri = "MyEventGridTopicUriSetting", topicKeySetting = "MyEventGridTopicKeySetting") OutputBinding<String> outputEvent final ExecutionContext context ) { context.getLogger().info(content); final String eventGridOutputDocument = "{\"id": "100", "eventType":"recordInserted", "subject": "myapp/test/java", "eventTime":"2017-08-10T21:03:07+00:00", "data": {"tag1": "value1","tag2":"value2"}, "dataVersion": "1.0"}"; outputEvent.setValue(eventGridOutputDocument); } |
EventGridTrigger |
EventGridTrigger(name = "event") String content, final ExecutionContext context ) { context.getLogger().info(content); } |
EventHubOutput |
TimerTrigger(name = "sendTimeTrigger", schedule = "0 */5 * * * *") String timerInfo ) { return LocalDateTime.now().toString(); } |
EventHubTrigger |
EventHubTrigger(name = "event", eventHubName = "samples-workitems", connection = "AzureEventHubConnection") String message, final ExecutionContext context ) { context.getLogger().info("Event hub message received: " + message); } |
ExponentialBackoffRetry |
Defines an exponential backoff retry strategy, where the delay between retries will get progressively larger, limited by the max/min specified. |
FixedDelayRetry |
Defines a retry strategy where a fixed delay is used between retries. |
FunctionName |
HttpTrigger(name = "req", methods = {"get"}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request) { .... } |
HttpOutput |
Place this on a parameter whose value would be send back to the user as an HTTP response. The parameter type should be OutputBinding<T>, where T could be one of:
|
HttpTrigger |
HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) final HttpRequestMessage<Optional<String>> request) { String name = request.getBody().orElseGet(() -> request.getQueryParameters().get("name")); return name == null ? "Please pass a name on the query string or in the request body" : "Hello " + name; } |
KafkaOutput |
KafkaOutput(name = "event", topic = "users", brokerList="broker:29092") OutputBinding<String<output, final ExecutionContext context) { context.getLogger().info("Message:" + message); output.setValue(message); return "{ \"id": "" + System.currentTimeMillis() + "", "description": "" + message + "" }"; } |
KafkaTrigger |
KafkaTrigger(name = "kafkaTrigger", topic = "users", brokerList="broker:29092", consumerGroup="functions") List<Map<String, String>> kafkaEventData, final ExecutionContext context ) { context.getLogger().info(kafkaEventData); } |
QueueOutput |
HttpOutput(name = "response") final OutputBinding<String> result ) { result.setValue(message + " has been added."); return message; } |
QueueTrigger |
QueueTrigger(name = "msg", queueName = "myqueue-items", connection = "AzureWebJobsStorage") String message, final ExecutionContext context ) { context.getLogger().info("Queue message processed: " + message); } |
SendGridOutput |
Place this on a parameter whose value would be written to SendGrid. The parameter type should be OutputBinding<T>, where T could be one of:
|
ServiceBusQueueOutput |
HttpOutput(name = "response") final OutputBinding<String> result ) { result.setValue(message + " has been sent."); return message; } |
ServiceBusQueueTrigger |
ServiceBusQueueTrigger(name = "msg", queueName = "myqueue", connection = "AzureServiceBusConnection") final String message, final ExecutionContext context ) { context.getLogger().info("Message is received: " + message); } |
ServiceBusTopicOutput |
Place this on a parameter whose value would be written to a service bus topic. The parameter type should be OutputBinding<T>, where T could be one of:
|
ServiceBusTopicTrigger |
ServiceBusTopicTrigger(name = "msg", topicName = "mytopicname", subscriptionName = "mysubname", connection = "myconnvarname") String message, final ExecutionContext context ) { context.getLogger().info(message); } |
StorageAccount |
Apply this annotation to a method if you have multiple Azure Storage triggers/input/output in that method which share the same app setting name of Azure Storage connection string. |
TableInput |
TableInput(name = "items", tableName = "mytablename", partitionKey = "myparkey", connection = "myconnvarname") MyItem[] items ) { return items.length; } |
TableOutput |
Place this on a parameter whose value would be written to a storage table. The parameter type should be OutputBinding<T>, where T could be one of:
|
TimerTrigger |
TimerTrigger(name = "keepAliveTrigger", schedule = "0 */5 * * * *") String timerInfo, ExecutionContext context ) { // timeInfo is a JSON string, you can deserialize it to an object using your favorite JSON library context.getLogger().info("Timer is triggered: " + timerInfo); } |
TwilioSmsOutput |
Place this on a parameter whose value would be sent through twilio SMS. The parameter type should be OutputBinding<T>, where T could be one of:
|
Enums
AccessRights |
Azure Service Bus permission. |
AuthorizationLevel |
Azure HTTP authorization level, Determines what keys, if any, need to be present on the request in order to invoke the function. |
Cardinality |
Cardinality of the EventHubTrigger input. Choose 'ONE' if the input is a single message or 'Many' if the input is an array of messages. 'Many' is the default if unspecified |