-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate official Azure Function templates with Functions Plugin (#59)
- Loading branch information
Showing
11 changed files
with
301 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
azure-functions-maven-plugin/src/it/http-trigger/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Build output | ||
target/ | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
# IDE | ||
.idea/ | ||
*.iml | ||
|
||
# macOS | ||
.DS_Store |
27 changes: 27 additions & 0 deletions
27
azure-functions-maven-plugin/src/it/http-trigger/cleanup.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
// Verify Azure Functions | ||
def url = "https://maven-functions-it-${timestamp}.azurewebsites.net/api/hello?name=Azure".toURL() | ||
try { | ||
url.getText() // warm up | ||
} catch (Exception e) { | ||
// ignore warm-up exception | ||
} | ||
def response = url.getText() | ||
assert response == "Hello, Azure" | ||
|
||
// Clean up resources created in test | ||
def clientId = System.getenv("CLIENT_ID") | ||
def tenantId = System.getenv("TENANT_ID") | ||
def key = System.getenv("KEY") | ||
def command = """ | ||
az login --service-principal -u ${clientId} -p ${key} --tenant ${tenantId} | ||
az group delete -y -n maven-functions-it-rg-1 --no-wait | ||
az logout | ||
""" | ||
def process = ["bash", "-c", command].execute() | ||
println process.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
azure-functions-maven-plugin/src/it/http-trigger/local.settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"AzureWebJobsStorage": "", | ||
"AzureWebJobsDashboard": "" | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
azure-functions-maven-plugin/src/it/http-trigger/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.microsoft.azure</groupId> | ||
<artifactId>azure-java-functions</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>Azure Java Functions</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<functionAppName>maven-functions-it-${timestamp}</functionAppName> | ||
<functionAppRegion>westus</functionAppRegion> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.microsoft.azure</groupId> | ||
<artifactId>azure-functions-java-core</artifactId> | ||
<version>1.0.0-beta-1</version> | ||
</dependency> | ||
|
||
<!-- Test --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<version>@project.version@</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<configuration> | ||
<authentication> | ||
<serverId>azure-auth</serverId> | ||
</authentication> | ||
<resourceGroup>maven-functions-it-rg-1</resourceGroup> | ||
<appName>${functionAppName}</appName> | ||
<region>${functionAppRegion}</region> | ||
<appSettings> | ||
<property> | ||
<name>FUNCTIONS_EXTENSION_VERSION</name> | ||
<value>beta</value> | ||
</property> | ||
</appSettings> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>package-functions</id> | ||
<goals> | ||
<goal>package</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-resources</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<configuration> | ||
<overwrite>true</overwrite> | ||
<outputDirectory>${project.build.directory}/azure-functions/${functionAppName} | ||
</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>${project.basedir}</directory> | ||
<includes> | ||
<include>host.json</include> | ||
<include>local.settings.json</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
|
||
</project> |
17 changes: 17 additions & 0 deletions
17
azure-functions-maven-plugin/src/it/http-trigger/setup.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
// Delete resources before test | ||
def clientId = System.getenv("CLIENT_ID") | ||
def tenantId = System.getenv("TENANT_ID") | ||
def key = System.getenv("KEY") | ||
def command = """ | ||
az login --service-principal -u ${clientId} -p ${key} --tenant ${tenantId} | ||
az group delete -y -n maven-functions-it-rg-1 | ||
az logout | ||
""" | ||
def process = ["bash", "-c", command].execute() | ||
println process.text |
40 changes: 40 additions & 0 deletions
40
...unctions-maven-plugin/src/it/http-trigger/src/main/java/com/microsoft/azure/Function.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.microsoft.azure; | ||
|
||
import com.microsoft.azure.serverless.functions.annotation.*; | ||
import com.microsoft.azure.serverless.functions.*; | ||
|
||
/** | ||
* Azure Functions with HTTP Trigger. | ||
*/ | ||
public class Function { | ||
@FunctionName("hello") | ||
public HttpResponseMessage httpHandler( | ||
@HttpTrigger(name = "req", methods = {"get", "post"}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage request, | ||
final ExecutionContext context | ||
) { | ||
context.getLogger().info("Java HTTP trigger processed a HTTP request."); | ||
|
||
// Parse query parameter | ||
String name = request.getQueryParameters().get("name"); | ||
|
||
if (name == null) { | ||
// Get request body | ||
Object body = request.getBody(); | ||
if (body != null) { | ||
name = body.toString(); | ||
} | ||
} | ||
|
||
if (name == null) { | ||
return request.createResponse(400, "Please pass a name on the query string or in the request body"); | ||
} else { | ||
return request.createResponse(200, "Hello, " + name); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<settings> | ||
<servers> | ||
<server> | ||
<id>azure-auth</id> | ||
<configuration> | ||
<client>${env.CLIENT_ID}</client> | ||
<tenant>${env.TENANT_ID}</tenant> | ||
<key>${env.KEY}</key> | ||
<environment>AZURE</environment> | ||
</configuration> | ||
</server> | ||
</servers> | ||
<profiles> | ||
<profile> | ||
<id>it-repo</id> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
<repositories> | ||
<repository> | ||
<id>local.central</id> | ||
<url>@localRepositoryUrl@</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>local.central</id> | ||
<url>@localRepositoryUrl@</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
</profile> | ||
</profiles> | ||
</settings> |
Oops, something went wrong.