你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

com.microsoft.azure.functions.annotation

版权所有 (c) Microsoft Corporation。 保留所有权利。 根据 MIT 许可证获得许可。 有关许可证信息,请参阅项目根目录中的 License.txt。 注释和支持类,用作 java API for Azure Functions的一部分。

BindingTest

对 Functions 强制实施注释协定和约定的单元测试

接口

BindingName

将此值放在参数上,其值将来自运行时Azure Functions。 如果要获取触发器元数据的值,或者在 function.json 中手动定义自己的绑定,请使用此批注。

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 () is/are inserted.”) ;如果 (!items.isEmpty () ) { context.getLogger () .info (“第一项的 ID 为:” + 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 *&#47;5 * * * *”) String timerInfo ) { return LocalDateTime.now () .toString () ; }

EventHubTrigger

EventHubTrigger (name = “event”, eventHubName = “samples-workitems”, connection = “AzureEventHubConnection”) String message, final ExecutionContext context ) { context.getLogger () .info (“接收的事件中心消息: ” + message) ; }

ExponentialBackoffRetry

定义指数退避重试策略,其中重试之间的延迟将逐渐变大,受指定最大值/最小值的限制。

FixedDelayRetry

定义重试策略,其中重试之间使用固定延迟。

FunctionName

HttpTrigger (name = “req”, methods = {“get”}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<可选<字符串>> 请求) { .... }

HttpOutput

将其放在参数上,其值将作为 HTTP 响应发送回给用户。 参数类型应为 OutputBinding<T>,其中 T 可以是以下类型之一:

    <li>
    
      <p>
    
        <xref uid="com.microsoft.azure.functions.HttpResponseMessage" data-throw-if-not-resolved="false" data-raw-source="HttpResponseMessage"></xref>
    
      </p>
    
    </li>
    
    <li>
    
      <p>Any native Java types such as int, String, byte[] </p>
    
    </li>
    
    <li>
    
      <p>Any POJO type </p>
    
    </li>
    

HttpTrigger

HttpTrigger (name = “req”, methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) 最终 HttpRequestMessage<可选<字符串>> 请求) { String name = request.getBody () .orElseGet ( () -> request.getQueryParameters () .get (“name”) ) ; return name == null ? “请在查询字符串或请求正文中传递名称”: “Hello” + name; }

KafkaOutput

KafkaOutput (name = “event”, topic = “users”, brokerList=“broker:29092”) OutputBinding<String<output, final ExecutionContext context) { context.getLogger () .info (“Message:” + message) ;output.setValue (消息) ;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”) 最终 OutputBinding<String> result ) { result.setValue (message + “ 已添加。) ;返回消息;}

QueueTrigger

QueueTrigger (name = “msg”, queueName = “myqueue-items”, connection = “AzureWebJobsStorage”) String message, final ExecutionContext context ) { context.getLogger () .info (“Queue message processed: ” + message) ; }

SendGridOutput

将此值放在其值将写入 SendGrid 的参数上。 参数类型应为 OutputBinding<T>,其中 T 可以是以下类型之一:

    <li>
    
      <p>Any native Java types such as int, String, byte[] </p>
    
    </li>
    
    <li>
    
      <p>Any POJO type </p>
    
    </li>
    

ServiceBusQueueOutput

HttpOutput (name = “response”) 最终 OutputBinding<String> result ) { result.setValue (message + “已发送。) ;返回消息;}

ServiceBusQueueTrigger

ServiceBusQueueTrigger (name = “msg”, queueName = “myqueue”, connection = “AzureServiceBusConnection”) final String message, final ExecutionContext context ) { context.getLogger () .info (“Message is received: ” + message) ; }

ServiceBusTopicOutput

将此值放在参数上,其值将写入服务总线主题。 参数类型应为 OutputBinding<T>,其中 T 可以是以下类型之一:

    <li>
    
      <p>Any native Java types such as int, String, byte[] </p>
    
    </li>
    
    <li>
    
      <p>Any POJO type </p>
    
    </li>
    

ServiceBusTopicTrigger

ServiceBusTopicTrigger (name = “msg”, topicName = “mytopicname”, subscriptionName = “mysubname”, connection = “myconnvarname”) String message, final ExecutionContext context ) { context.getLogger () .info (message) ; }

StorageAccount

如果该方法中有多个共享 Azure 存储连接字符串的应用设置名称的 Azure 存储触发器/输入/输出,请将此注释应用于方法。

TableInput

TableInput (name = “items”, tableName = “mytablename”, partitionKey = “myparkey”, connection = “myconnvarname”) MyItem[] items ) { return items.length; }

TableOutput

将此值放在参数上,其值将写入存储表。 参数类型应为 OutputBinding<T>,其中 T 可以是以下类型之一:

    <li>
    
      <p>Any native Java types such as int, String, byte[] </p>
    
    </li>
    
    <li>
    
      <p>Any POJO type </p>
    
    </li>
    

TimerTrigger

TimerTrigger (name = “keepAliveTrigger”, schedule = “0 *&#47;5 * * * *”) String timerInfo,ExecutionContext 上下文 ) { // timeInfo 是 JSON 字符串,可以使用偏好的 JSON 库 context.getLogger () .info (“Timer 触发:” + timerInfo) ; }

TwilioSmsOutput

将此值放在将通过 twilio SMS 发送其值的参数上。 参数类型应为 OutputBinding<T>,其中 T 可以是以下类型之一:

    <li>
    
      <p>Any native Java types such as int, String, byte[] </p>
    
    </li>
    
    <li>
    
      <p>Any POJO type </p>
    
    </li>
    

枚举

AccessRights

Azure 服务总线权限。

AuthorizationLevel

Azure HTTP 授权级别确定请求中需要提供哪些密钥(如果有)才能调用函数。

Cardinality

EventHubTrigger 输入的基数。 如果输入是单个消息,请选择“ONE”;如果输入是消息数组,则选择“多”。 如果未指定,则为默认值“Many”