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

TimerTrigger 接口

public interface TimerTrigger

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

方法摘要

修饰符和类型 方法和描述
String dataType()

定义 Functions 运行时应如何处理参数值。 可能的值为:

    <li>
    
      <p>"": get the value as a string, and try to deserialize to actual parameter type like POJO </p>
    
    </li>
    
    <li>
    
      <p>string: always get the value as a string </p>
    
    </li>
    
    <li>
    
      <p>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[] </p>
    
    </li>
    

String name()

在函数代码中表示计时器对象的变量的名称。

String schedule()

格式为 {minute} {hour} {day} {month} {day-of-week} 的 CRON 表达式

</code> .</p>

<caption>A table showing some examples of CRON expressions that could be used.</caption>

<row>

  <entry thead="yes">

    <p>Goal </p>

  </entry>

  <entry thead="yes">

    <p>CRON Expression  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every five minutes: </p>

  </entry>

  <entry thead="no">

    <p>0 *&amp;#47;5 * * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once at the top of every hour: </p>

  </entry>

  <entry thead="no">

    <p>0 0 * * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every two hours: </p>

  </entry>

  <entry thead="no">

    <p>0 0 *&amp;#47;2 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every hour from 9 AM to 5 PM: </p>

  </entry>

  <entry thead="no">

    <p>0 0 9-17 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger at 9:30 AM every day: </p>

  </entry>

  <entry thead="no">

    <p>0 30 9 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger at 9:30 AM every weekday: </p>

  </entry>

  <entry thead="no">

    <p>0 30 9 * * 1-5  </p>

  </entry>

</row>

方法详细信息

dataType

public String dataType() default ""

定义 Functions 运行时应如何处理参数值。 可能的值为:

    <li>
    
      <p>"": get the value as a string, and try to deserialize to actual parameter type like POJO </p>
    
    </li>
    
    <li>
    
      <p>string: always get the value as a string </p>
    
    </li>
    
    <li>
    
      <p>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[] </p>
    
    </li>
    

Returns:

将由 Functions 运行时使用的 dataType。

name

public String name()

在函数代码中表示计时器对象的变量的名称。

Returns:

在函数代码中表示计时器对象的变量的名称。

schedule

public String schedule()

格式为 {minute} {hour} {day} {month} {day-of-week} 的 CRON 表达式

</code> .</p>

<caption>A table showing some examples of CRON expressions that could be used.</caption>

<row>

  <entry thead="yes">

    <p>Goal </p>

  </entry>

  <entry thead="yes">

    <p>CRON Expression  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every five minutes: </p>

  </entry>

  <entry thead="no">

    <p>0 *&amp;#47;5 * * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once at the top of every hour: </p>

  </entry>

  <entry thead="no">

    <p>0 0 * * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every two hours: </p>

  </entry>

  <entry thead="no">

    <p>0 0 *&amp;#47;2 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every hour from 9 AM to 5 PM: </p>

  </entry>

  <entry thead="no">

    <p>0 0 9-17 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger at 9:30 AM every day: </p>

  </entry>

  <entry thead="no">

    <p>0 30 9 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger at 9:30 AM every weekday: </p>

  </entry>

  <entry thead="no">

    <p>0 30 9 * * 1-5  </p>

  </entry>

</row>

Returns:

一个字符串,表示将用于计划要运行的函数的 CRON 表达式。

适用于