Skip to content

Commit a5a92da

Browse files
Merge pull request #224284 from ggailey777/java
[Functions] Fix Java options
2 parents 12ccde4 + 5b1204e commit a5a92da

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

articles/azure-functions/functions-reference-java.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ ms.custom: devx-track-java, devx-track-azurecli, ignite-2022
1111

1212
This guide contains detailed information to help you succeed developing Azure Functions using Java.
1313

14-
As a Java developer, if you're new to Azure Functions, please consider first reading one of the following articles:
14+
As a Java developer, if you're new to Azure Functions, consider first reading one of the following articles:
1515

1616
| Getting started | Concepts| Scenarios/samples |
1717
| -- | -- | -- |
18-
| <ul><li>[Java function using Visual Studio Code](./create-first-function-vs-code-java.md)</li><li>[Java/Maven function with terminal/command prompt](./create-first-function-cli-java.md)</li><li>[Java function using Gradle](functions-create-first-java-gradle.md)</li><li>[Java function using Eclipse](functions-create-maven-eclipse.md)</li><li>[Java function using IntelliJ IDEA](functions-create-maven-intellij.md)</li></ul> | <ul><li>[Developer guide](functions-reference.md)</li><li>[Hosting options](functions-scale.md)</li><li>[Performance&nbsp; considerations](functions-best-practices.md)</li></ul> | <ul><li>[Java samples with different triggers](/samples/azure-samples/azure-functions-samples-java/azure-functions-java/)</li><li>[Event Hub trigger and Azure Cosmos DB output binding](/samples/azure-samples/java-functions-eventhub-cosmosdb/sample/)</li></ul> |
18+
| <ul><li>[Java function using Visual Studio Code](./create-first-function-vs-code-java.md)</li><li>[Java/Maven function with terminal/command prompt](./create-first-function-cli-java.md)</li><li>[Java function using Gradle](functions-create-first-java-gradle.md)</li><li>[Java function using Eclipse](functions-create-maven-eclipse.md)</li><li>[Java function using IntelliJ IDEA](functions-create-maven-intellij.md)</li></ul> | <ul><li>[Developer guide](functions-reference.md)</li><li>[Hosting options](functions-scale.md)</li><li>[Performance&nbsp; considerations](functions-best-practices.md)</li></ul> | <ul><li>[Java samples with different triggers](/samples/azure-samples/azure-functions-samples-java/azure-functions-java/)</li><li>[Event Hubs trigger and Azure Cosmos DB output binding](/samples/azure-samples/java-functions-eventhub-cosmosdb/sample/)</li></ul> |
1919

2020
## Java function basics
2121

22-
A Java function is a `public` method, decorated with the annotation `@FunctionName`. This method defines the entry for a Java function, and must be unique in a particular package. The package can have multiple classes with multiple public methods annotated with `@FunctionName`. A single package is deployed to a function app in Azure. When running in Azure, the function app provides the deployment, execution, and management context for your individual Java functions.
22+
A Java function is a `public` method, decorated with the annotation `@FunctionName`. This method defines the entry for a Java function, and must be unique in a particular package. The package can have multiple classes with multiple public methods annotated with `@FunctionName`. A single package is deployed to a function app in Azure. In Azure, the function app provides the deployment, execution, and management context for your individual Java functions.
2323

2424
## Programming model
2525

@@ -37,9 +37,9 @@ The following developer environments have Azure Functions tooling that lets you
3737
+ [Eclipse](functions-create-maven-eclipse.md)
3838
+ [IntelliJ](functions-create-maven-intellij.md)
3939

40-
The article links above show you how to create your first functions using your IDE of choice.
40+
These articles show you how to create your first functions using your IDE of choice.
4141

42-
### Project Scaffolding
42+
### Project scaffolding
4343

4444
If you prefer command line development from the Terminal, the simplest way to scaffold Java-based function projects is to use `Apache Maven` archetypes. The Java Maven archetype for Azure Functions is published under the following _groupId_:_artifactId_: [com.microsoft.azure:azure-functions-archetype](https://search.maven.org/artifact/com.microsoft.azure/azure-functions-archetype/).
4545

@@ -67,7 +67,7 @@ To get started using this archetype, see the [Java quickstart](./create-first-fu
6767

6868
## Folder structure
6969

70-
Here is the folder structure of an Azure Functions Java project:
70+
Here's the folder structure of an Azure Functions Java project:
7171

7272
```
7373
FunctionsProject
@@ -116,7 +116,7 @@ public class Function {
116116
}
117117
```
118118

119-
Here is the generated corresponding `function.json` by the [azure-functions-maven-plugin](https://mvnrepository.com/artifact/com.microsoft.azure/azure-functions-maven-plugin):
119+
Here's the generated corresponding `function.json` by the [azure-functions-maven-plugin](https://mvnrepository.com/artifact/com.microsoft.azure/azure-functions-maven-plugin):
120120

121121
```json
122122
{
@@ -142,7 +142,7 @@ Here is the generated corresponding `function.json` by the [azure-functions-mave
142142

143143
## Java versions
144144

145-
The version of Java used when creating the function app on which functions runs in Azure is specified in the pom.xml file. The Maven archetype currently generates a pom.xml for Java 8, which you can change before publishing. The Java version in pom.xml should match the version on which you have locally developed and tested your app.
145+
The version of Java on which your app runs in Azure is specified in the pom.xml file. The Maven archetype currently generates a pom.xml for Java 8, which you can change before publishing. The Java version in pom.xml should match the version on which you've locally developed and tested your app.
146146

147147
### Supported versions
148148

@@ -192,11 +192,11 @@ The following example shows the operating system setting in the `runtime` sectio
192192

193193
## JDK runtime availability and support
194194

195-
Microsoft and [Adoptium](https://adoptium.net/) builds of OpenJDK are provided and supported on Functions for Java 8 (Adoptium), 11 (MSFT) and 17(MSFT). These binaries are provided as a no-cost, multi-platform, production-ready distribution of the OpenJDK for Azure. They contain all the components for building and runnning Java SE applications.
195+
Microsoft and [Adoptium](https://adoptium.net/) builds of OpenJDK are provided and supported on Functions for Java 8 (Adoptium), 11 (MSFT) and 17(MSFT). These binaries are provided as a no-cost, multi-platform, production-ready distribution of the OpenJDK for Azure. They contain all the components for building and running Java SE applications.
196196

197197
For local development or testing, you can download the [Microsoft build of OpenJDK](/java/openjdk/download) or [Adoptium Temurin](https://adoptium.net/?variant=openjdk8&jvmVariant=hotspot) binaries for free. [Azure support](https://azure.microsoft.com/support/) for issues with the JDKs and function apps is available with a [qualified support plan](https://azure.microsoft.com/support/plans/).
198198

199-
If you would like to continue using the Zulu for Azure binaries on your Function app, please [configure your app accordingly](https://github.com/Azure/azure-functions-java-worker/wiki/Customize-JVM-to-use-Zulu). You can continue to use the Azul binaries for your site, but any security patches or improvements will only be available in new versions of the OpenJDK, so we recommend that you eventually remove this configuration so that your Function apps use the latest available version of Java.
199+
If you would like to continue using the Zulu for Azure binaries on your Function app, [configure your app accordingly](https://github.com/Azure/azure-functions-java-worker/wiki/Customize-JVM-to-use-Zulu). You can continue to use the Azul binaries for your site. However, any security patches or improvements are only available in new versions of the OpenJDK. Because of this, you should eventually remove this configuration so that your apps use the latest available version of Java.
200200

201201
## Customize JVM
202202

@@ -208,34 +208,36 @@ Functions lets you customize the Java virtual machine (JVM) used to run your Jav
208208
* `-Djava.net.preferIPv4Stack=true`
209209
* `-jar`
210210

211-
You can provide additional arguments in an app setting named `JAVA_OPTS`. You can add app settings to your function app deployed to Azure in the Azure portal or the Azure CLI.
211+
You can provide other arguments to the JVM by using one of the following application settings, depending on the plan type:
212212

213-
> [!IMPORTANT]
214-
> In the Consumption plan, you must also add the WEBSITE_USE_PLACEHOLDER setting with a value of 0 for the customization to work. This setting does increase the cold start times for Java functions.
213+
| Plan type | Setting name | Comment |
214+
| --- | --- |
215+
| [Consumption plan](./consumption-plan.md) | `languageWorkers__java__arguments` | This setting does increase the cold start times for Java functions running in a Consumption plan. |
216+
| [Premium plan](./functions-premium-plan.md)<br/>[Dedicated plan](./dedicated-plan.md) | `JAVA_OPTS` | |
217+
218+
The following sections show you how to add these settings. To learn more about working with application settings, see the [Work with application settings](./functions-how-to-use-azure-function-app-settings.md#settings) section.
215219

216220
### Azure portal
217221

218-
In the [Azure portal](https://portal.azure.com), use the [Application Settings tab](functions-how-to-use-azure-function-app-settings.md#settings) to add the `JAVA_OPTS` setting.
222+
In the [Azure portal](https://portal.azure.com), use the [Application Settings tab](functions-how-to-use-azure-function-app-settings.md#settings) to add either the `languageWorkers__java__arguments` or the `JAVA_OPTS` setting.
219223

220224
### Azure CLI
221225

222-
You can use the [az functionapp config appsettings set](/cli/azure/functionapp/config/appsettings) command to set `JAVA_OPTS`, as in the following example:
226+
You can use the [az functionapp config appsettings set](/cli/azure/functionapp/config/appsettings) command to add these settings, as shown in the following example for the `-Djava.awt.headless=true` option:
223227

224228
# [Consumption plan](#tab/consumption/bash)
225229

226230
```azurecli-interactive
227231
az functionapp config appsettings set \
228-
--settings "JAVA_OPTS=-Djava.awt.headless=true" \
229-
"WEBSITE_USE_PLACEHOLDER=0" \
232+
--settings "languageWorkers__java__arguments=-Djava.awt.headless=true" \
230233
--name <APP_NAME> --resource-group <RESOURCE_GROUP>
231234
```
232235

233236
# [Consumption plan](#tab/consumption/cmd)
234237

235238
```azurecli-interactive
236239
az functionapp config appsettings set ^
237-
--settings "JAVA_OPTS=-Djava.awt.headless=true" ^
238-
"WEBSITE_USE_PLACEHOLDER=0" ^
240+
--settings "languageWorkers__java__arguments=-Djava.awt.headless=true" ^
239241
--name <APP_NAME> --resource-group <RESOURCE_GROUP>
240242
```
241243

@@ -352,7 +354,7 @@ To receive a batch of inputs, you can bind to `String[]`, `POJO[]`, `List<String
352354

353355
```
354356

355-
This function gets triggered whenever there is new data in the configured event hub. Because the `cardinality` is set to `MANY`, the function receives a batch of messages from the event hub. `EventData` from event hub gets converted to `TestEventData` for the function execution.
357+
This function gets triggered whenever there's new data in the configured event hub. Because the `cardinality` is set to `MANY`, the function receives a batch of messages from the event hub. `EventData` from event hub gets converted to `TestEventData` for the function execution.
356358

357359
### Output binding example
358360

@@ -413,7 +415,7 @@ You invoke this function on an `HttpRequest` object. It writes multiple values t
413415

414416
## HttpRequestMessage and HttpResponseMessage
415417

416-
These are defined in `azure-functions-java-library`. They are helper types to work with HttpTrigger functions.
418+
These are defined in `azure-functions-java-library`. They're helper types to work with HttpTrigger functions.
417419

418420
| Specialized type | Target | Typical usage |
419421
| --------------------- | :-----------------: | ------------------------------ |
@@ -488,7 +490,7 @@ public class Function {
488490

489491
## View logs and trace
490492

491-
You can use the Azure CLI to stream Java stdout and stderr logging, as well as other application logging.
493+
You can use the Azure CLI to stream Java stdout and stderr logging, and other application logging.
492494

493495
Here's how to configure your function app to write application logging by using the Azure CLI:
494496

0 commit comments

Comments
 (0)