Permalink
Browse files

Altri esempi

  • Loading branch information...
fpaparoni committed Jan 29, 2018
1 parent cc48841 commit 2f78cf9c98c2c211d9d4be70801f78946d060760
20 pom.xml
@@ -20,6 +20,11 @@
</properties>
<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb</artifactId>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-java-core</artifactId>
@@ -57,11 +62,24 @@
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-maven-plugin</artifactId>
<configuration>
<resourceGroup>java-functions-group</resourceGroup>
<resourceGroup>azure.functions.rg</resourceGroup>
<appName>${functionAppName}</appName>
<region>${functionAppRegion}</region>
<appSettings>
@@ -0,0 +1,27 @@
package com.javastaff.azure.functions;
import java.util.Calendar;
import java.util.UUID;
import com.microsoft.azure.documentdb.Document;
import com.microsoft.azure.serverless.functions.ExecutionContext;
import com.microsoft.azure.serverless.functions.annotation.*;
public class DocumentDBFunction {
@FunctionName("documentDBFunction")
@DocumentDBOutput(name = "documentDb",
databaseName = "functionDb",
collectionName="functionMessage",
connection = "CosmosDBConnectionString")
public Document functionHandler(
@TimerTrigger(name = "timerInfo", schedule = "*/30 * * * * *") String timerInfo,
final ExecutionContext executionContext) {
String randomString=UUID.randomUUID().toString();
executionContext.getLogger().info("Funzione attivata dal trigger: " + timerInfo);
executionContext.getLogger().info("Inserisco oggetto in documentDB: " + randomString);
Document document=new Document();
document.set("uuid", randomString);
document.set("timestamp", Calendar.getInstance().getTime());
return document;
}
}
@@ -0,0 +1,15 @@
package com.javastaff.azure.functions;
import com.microsoft.azure.serverless.functions.ExecutionContext;
import com.microsoft.azure.serverless.functions.annotation.*;
public class QueueFunction {
@FunctionName("queueFunction")
public void functionHandler(
@QueueTrigger(name = "queueItem",
queueName = "codaMessaggiInArrivo",
connection = "AzureWebJobsStorage") String queueItem,
final ExecutionContext executionContext) {
executionContext.getLogger().info("Arrivato il seguente messaggio in coda: " + queueItem);
}
}
@@ -0,0 +1,19 @@
package com.javastaff.azure.functions;
import java.util.UUID;
import com.microsoft.azure.serverless.functions.ExecutionContext;
import com.microsoft.azure.serverless.functions.annotation.*;
public class TimerFunction {
@FunctionName("timerFunction")
@QueueOutput(name = "queueItem", queueName = "codaMessaggiInArrivo", connection = "AzureWebJobsStorage")
public String functionHandler(
@TimerTrigger(name = "timerInfo", schedule = "*/30 * * * * *") String timerInfo,
final ExecutionContext executionContext) {
String randomString=UUID.randomUUID().toString();
executionContext.getLogger().info("Funzione attivata dal trigger: " + timerInfo);
executionContext.getLogger().info("Inserisco messaggio random nella coda: " + randomString);
return randomString;
}
}

0 comments on commit 2f78cf9

Please sign in to comment.