Skip to content

Commit

Permalink
Add TimerTrigger sample (Azure#31).
Browse files Browse the repository at this point in the history
  • Loading branch information
Junyi Yi committed Jul 20, 2018
1 parent 68d16d0 commit 1e4a7c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
* public HttpResponseMessage<String> helloFunction(
* {@literal @}HttpTrigger(name = "req",
* methods = {HttpMethod.GET},
* authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request) {
* authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request
* ) {
* ....
* }</pre>
*
Expand Down Expand Up @@ -62,27 +63,26 @@
* {@literal @}FunctionName("readHttpName")
* public String readName(
* {@literal @}HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS)
* final HttpRequestMessage&lt;Optional&lt;String&gt;&gt; request) {
* final HttpRequestMessage&lt;Optional&lt;String&gt;&gt; request
* ) {
* String name = request.getBody().orElseGet(() -&gt; request.getQueryParameters().get("name"));
* return name == null ?
* "Please pass a name on the query string or in the request body" :
* "Hello " + name;
* }
* </pre>
* }</pre>
*
* <p>The following example shows a webhook trigger binding in Java function. The function logs GitHub issue comments.</p>
*
* <pre>
* {@literal @}FunctionName("logGithubIssues")
* public String logIssues(
* {@literal @}HttpTrigger(name = "req", webHookType = WebHookType.GITHUB)
* final String content,
* ExecutionContext context) {
* {@literal @}HttpTrigger(name = "req", webHookType = WebHookType.GITHUB) final String content,
* ExecutionContext context
* ) {
* context.getLogger().info("WebHook was triggered!");
* context.getLogger().info("Content is " + content);
* return "New GitHub comment: " + content;
* }
* </pre>
* }</pre>
*
* @see com.microsoft.azure.functions.HttpRequestMessage
* @see com.microsoft.azure.functions.HttpResponseMessage
Expand Down Expand Up @@ -131,7 +131,8 @@
* route = "products/{category:alpha}/{id:int}") HttpRequestMessage&lt;Optional&lt;String&gt;&gt; request,
* {@literal @}BindingName("category") String category,
* {@literal @}BindingName("id") int id,
* final ExecutionContext context) {
* final ExecutionContext context
* ) {
* ....
* context.getLogger().info("We have " + category + " with id " + id);
* ....
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
* this annotation.
*
* <p>An example of using the timer trigger is shown below, where the {@code keepAlive} function is set to trigger and
* execute every four minutes:</p>
* execute every five minutes:</p>
*
* <pre>
* {@literal @}FunctionName("keepAlive")
* public void keepAlive(@TimerTrigger(name = "keepAliveTrigger", schedule = "0 *&#47;4 * * * *") String timerInfo) { .. }
* </pre>
* public void keepAlive(
* {@literal @}TimerTrigger(name = "keepAliveTrigger", schedule = "0 *&#47;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);
* }</pre>
*
* @since 1.0.0
*/
Expand Down

0 comments on commit 1e4a7c5

Please sign in to comment.