Skip to content

Commit

Permalink
Merge pull request #14949 from patriot1burke/azure-java-11
Browse files Browse the repository at this point in the history
Azure Functions upgrade and java 11
  • Loading branch information
gastaldi authored Feb 11, 2021
2 parents f3ea5fa + 5d84904 commit 16326d6
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 47 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<aws-xray.version>2.4.0</aws-xray.version>
<awssdk.version>2.15.79</awssdk.version>
<aws-alexa-sdk.version>2.37.1</aws-alexa-sdk.version>
<azure-functions-java-library.version>1.3.0</azure-functions-java-library.version>
<azure-functions-java-library.version>1.4.0</azure-functions-java-library.version>
<kotlin.version>1.4.20</kotlin.version>
<dekorate.version>0.14.2</dekorate.version>
<maven-artifact-transfer.version>0.10.0</maven-artifact-transfer.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"scriptFile" : "../{project.artifact-id}-{project.version}-runner.jar",
"scriptFile" : "../{project.artifact-id}-{project.version}.jar",
"entryPoint" : "io.quarkus.azure.functions.resteasy.runtime.Function.run",
"bindings" : [ {
"type" : "httpTrigger",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
<azure.functions.maven.plugin.version>1.3.2</azure.functions.maven.plugin.version>
<azure.functions.maven.plugin.version>1.9.1</azure.functions.maven.plugin.version>
<resources-plugin.version>3.1.0</resources-plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<functionAppName>$\{artifactId}-{gen-info.time}</functionAppName>
<functionAppRegion>{app-region}</functionAppRegion>
<functionResourceGroup>{resource-group}</functionResourceGroup>
Expand All @@ -23,21 +23,22 @@
<resourceGroup>$\{functionResourceGroup}</resourceGroup>
<appName>$\{functionAppName}</appName>
<region>$\{functionAppRegion}</region>
<runtime>
<!-- runtime os, could be windows, linux or docker-->
<os>windows</os>
<javaVersion>11</javaVersion>
<!-- for docker function, please set the following parameters -->
<!-- <image>[hub-user/]repo-name[:tag]</image> -->
<!-- <serverId></serverId> -->
<!-- <registryUrl></registryUrl> -->
</runtime>
<appSettings>
<!-- Run Azure Function from package file by default -->
<property>
<name>WEBSITE_RUN_FROM_PACKAGE</name>
<value>1</value>
</property>
<property>
<name>FUNCTIONS_EXTENSION_VERSION</name>
<value>~2</value>
</property>
<property>
<name>FUNCTIONS_WORKER_RUNTIME</name>
<value>java</value>
<value>~3</value>
</property>
</appSettings>
</appSettings>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -110,6 +111,25 @@
</execution>
</executions>
</plugin>
<!-- azure plugin wants a specific name for the jar so need to copy runner jar and rename it -->
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>rename-file</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>$\{project.build.directory}/$\{project.artifactId}-$\{project.version}-runner.jar</sourceFile>
<destinationFile>$\{stagingDirectory}/$\{project.artifactId}-$\{project.version}.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
2 changes: 2 additions & 0 deletions docs/src/main/asciidoc/azure-functions-http.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ One azure function deployment can represent any number of JAX-RS, servlet, Vert.

include::./status-include.adoc[]

NOTE: Only text based media types are supported at the moment as Azure Functions HTTP Trigger for Java does not support a binary format

== Prerequisites

To complete this guide, you need:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"scriptFile" : "../${project.build.finalName}-runner.jar",
"scriptFile" : "../${project.build.finalName}.jar",
"entryPoint" : "io.quarkus.azure.functions.resteasy.runtime.Function.run",
"bindings" : [ {
"type" : "httpTrigger",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>999-SNAPSHOT</quarkus-plugin.version>
Expand All @@ -19,7 +19,7 @@
<resources-plugin.version>3.1.0</resources-plugin.version>
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>

<azure.functions.maven.plugin.version>1.3.2</azure.functions.maven.plugin.version>
<azure.functions.maven.plugin.version>1.9.1</azure.functions.maven.plugin.version>
<functionAppName>${appName}</functionAppName>
<functionAppRegion>${appRegion}</functionAppRegion>
<functionResourceGroup>${resourceGroup}</functionResourceGroup>
Expand Down Expand Up @@ -112,19 +112,19 @@
<resourceGroup>${functionResourceGroup}</resourceGroup>
<appName>${functionAppName}</appName>
<region>${functionAppRegion}</region>
<runtime>
<!-- runtime os, could be windows, linux or docker-->
<os>windows</os>
<javaVersion>11</javaVersion>
<!-- for docker function, please set the following parameters -->
<!-- <image>[hub-user/]repo-name[:tag]</image> -->
<!-- <serverId></serverId> -->
<!-- <registryUrl></registryUrl> -->
</runtime>
<appSettings>
<!-- Run Azure Function from package file by default -->
<property>
<name>WEBSITE_RUN_FROM_PACKAGE</name>
<value>1</value>
</property>
<property>
<name>FUNCTIONS_EXTENSION_VERSION</name>
<value>~2</value>
</property>
<property>
<name>FUNCTIONS_WORKER_RUNTIME</name>
<value>java</value>
<value>~3</value>
</property>
</appSettings>
</configuration>
Expand Down Expand Up @@ -177,24 +177,23 @@
</resources>
</configuration>
</execution>
<!-- copy the uber-jar into Azure staging directory -->
</executions>
</plugin>
<!-- azure plugin wants a specific name for the jar so need to copy runner jar and rename it -->
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>copy-uberjar</id>
<phase>install</phase>
<id>rename-file</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
<goal>copy</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${stagingDirectory}</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<includes>
<include>${project.artifactId}-${project.version}-runner.jar</include>
</includes>
</resource>
</resources>
<sourceFile>${project.build.directory}/${project.artifactId}-${project.version}-runner.jar</sourceFile>
<destinationFile>${stagingDirectory}/${project.artifactId}-${project.version}.jar</destinationFile>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
public class BaseFunction {
private static final Logger log = Logger.getLogger("io.quarkus.azure");

protected static final String deploymentStatus;
protected static String deploymentStatus;
protected static boolean started = false;
protected static boolean bootstrapError = false;

private static final int BUFFER_SIZE = 8096;

static {
protected static void initQuarkus() {
StringWriter error = new StringWriter();
PrintWriter errorWriter = new PrintWriter(error, true);
if (Application.currentApplication() == null) { // were we already bootstrapped? Needed for mock azure unit testing.
Expand All @@ -50,7 +51,8 @@ public class BaseFunction {
app.start(args);
errorWriter.println("Quarkus bootstrapped successfully.");
started = true;
} catch (Exception ex) {
} catch (Throwable ex) {
bootstrapError = true;
errorWriter.println("Quarkus bootstrap failed.");
ex.printStackTrace(errorWriter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ public class Function extends BaseFunction {
public HttpResponseMessage run(
@HttpTrigger(name = "req") HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
if (!started) {
if (!started && !bootstrapError) {
initQuarkus();
}
if (bootstrapError) {
HttpResponseMessage.Builder responseBuilder = request
.createResponseBuilder(HttpStatus.valueOf(500)).body(
deploymentStatus.getBytes(StandardCharsets.UTF_8));
Expand Down

0 comments on commit 16326d6

Please sign in to comment.