Add sample code to all triggers. (#99)

This commit is contained in:
Junyi Yi 2018-05-03 19:32:06 -04:00 коммит произвёл GitHub
Родитель 1198d07fe9
Коммит 278696f375
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 104 добавлений и 0 удалений

Просмотреть файл

@ -12,7 +12,21 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p>The following example shows a storage blob trigger which logs the blob filename as well as its size:</p>
*
* <pre>{@literal @}FunctionName("blobprocessor")
* public void run(
* {@literal @}BlobTrigger(name = "file",
* dataType = "binary",
* path = "myblob/filepath",
* connection = "myconnvarname") byte[] content,
* {@literal @}BindingName("name") String filename,
* final ExecutionContext context
* ) {
* context.getLogger().info("Name: " + name + " Size: " + content.length + " bytes");
* }</pre>
*
* @see com.microsoft.azure.serverless.functions.annotation.BindingName
* @since 1.0.0
*/
@Retention(RetentionPolicy.RUNTIME)

Просмотреть файл

@ -12,6 +12,19 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p>The following example shows a cosmos db trigger which logs the count of the returned items:</p>
*
* <pre>{@literal @}FunctionName("cdbprocessor")
* public void cosmosDbProcessor(
* {@literal @}CosmosDBTrigger(name = "items",
* databaseName = "mydbname",
* collectionName = "mycollname",
* leaseCollectionName = "",
* connectionStringSetting = "myconnvarname") MyDataItem[] items,
* final ExecutionContext context
* ) {
* context.getLogger().info(items.length);
* }</pre>
*
* @since 1.0.0
*/

Просмотреть файл

@ -11,6 +11,19 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p>The following example shows an event grid trigger which prints out the object:</p>
*
* <pre>{@literal @}FunctionName("egprocessor")
* public void eventGridProcessor(
* {@literal @}EventGridTrigger(name = "obj") MyModel obj,
* final ExecutionContext context
* ) {
* context.getLogger().info(obj.toString());
* }</pre>
*
* @since 1.0.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
public @interface EventGridTrigger {

Просмотреть файл

@ -12,6 +12,17 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p>The following example shows an event hub trigger which logs the message:</p>
*
* <pre>{@literal @}FunctionName("ehprocessor")
* public void eventHubProcessor(
* {@literal @}EventHubTrigger(name = "msg",
* eventHubName = "myeventhubname",
* connection = "myconnvarname") String message,
* final ExecutionContext context
* ) {
* context.getLogger().info(message);
* }</pre>
*
* @since 1.0.0
*/

Просмотреть файл

@ -12,6 +12,17 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p>The following example shows a storage queue trigger which logs the message:</p>
*
* <pre>{@literal @}FunctionName("queueprocessor")
* public void run(
* {@literal @}QueueTrigger(name = "msg",
* queueName = "myqueuename",
* connection = "myconnvarname") String message,
* final ExecutionContext context
* ) {
* context.getLogger().info(message);
* }</pre>
*
* @since 1.0.0
*/

Просмотреть файл

@ -12,6 +12,21 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p>Use ServiceBusQueueTrigger annotation to respond to messages from a Service Bus queue. Similar to other annotations,
* ServiceBusQueueTrigger could be applied to a method parameter with any type (including String, int or any POJO) as long
* as the parameter is JSON-deserializable.</p>
*
* <p>The following example shows a service bus queue trigger which logs the queue message:</p>
*
* <pre>{@literal @}FunctionName("sbprocessor")
* public void serviceBusProcess(
* {@literal @}ServiceBusQueueTrigger(name = "msg",
* queueName = "myqueuename",
* connection = "myconnvarname") String message,
* final ExecutionContext context
* ) {
* context.getLogger().info(message);
* }</pre>
*
* @since 1.0.0
*/

Просмотреть файл

@ -12,6 +12,18 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p>The following example shows a service bus topic trigger which logs the message:</p>
*
* <pre>{@literal @}FunctionName("sbprocessor")
* public void serviceBusProcess(
* {@literal @}ServiceBusTopicTrigger(name = "msg",
* topicName = "mytopicname",
* subscriptionName = "mysubname",
* connection = "myconnvarname") String message,
* final ExecutionContext context
* ) {
* context.getLogger().info(message);
* }</pre>
*
* @since 1.0.0
*/

Просмотреть файл

@ -12,7 +12,22 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p>The following example shows an HTTP trigger which returned the total count of the items in a table storage:</p>
*
* <pre>{@literal @}FunctionName("getallcount")
* public int run(
* {@literal @}HttpTrigger(name = "req",
* methods = {"get"},
* authLevel = AuthorizationLevel.ANONYMOUS) Object dummyShouldNotBeUsed,
* {@literal @}TableInput(name = "items",
* tableName = "mytablename",
* partitionKey = "myparkey",
* connection = "myconnvarname") MyItem[] items
* ) {
* return items.length;
* }</pre>
*
* @see com.microsoft.azure.serverless.functions.annotation.HttpTrigger
* @since 1.0.0
*/
@Retention(RetentionPolicy.RUNTIME)