You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-reference-java.md
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ A function should be a stateless method to process input and produce output. Alt
25
25
26
26
## Folder structure
27
27
28
-
The folder structure for a Java project looks like the following:
28
+
Here is the folder structure of an Azure Function Java project:
29
29
30
30
```
31
31
FunctionsProject
@@ -57,7 +57,7 @@ You can put more than one function in a project. Avoid putting your functions in
57
57
58
58
Azure functions are invoked by a trigger, such as an HTTP request, a timer, or an update to data. Your function needs to process that trigger and any other inputs to produce one or more outputs.
59
59
60
-
Use the Java annotations included in the [com.microsoft.azure.functions.annotation.*](/java/api/com.microsoft.azure.functions.annotation) package to bind input and outputs to your methods. Sample code using the annotations is available in the [Java reference docs](/java/api/com.microsoft.azure.functions.annotation) for each annotation and in the Azure Functions binding reference documentation, such as the one for [HTTP triggers](/azure/azure-functions/functions-bindings-http-webhook).
60
+
Use the Java annotations included in the [com.microsoft.azure.functions.annotation.*](/java/api/com.microsoft.azure.functions.annotation) package to bind input and outputs to your methods. See [Java reference docs](/java/api/com.microsoft.azure.functions.annotation) for more details.
61
61
62
62
> [!IMPORTANT]
63
63
> You must configure an Azure Storage account in your [local.settings.json](/azure/azure-functions/functions-run-local#local-settings-file) to run Azure Storage Blob, Queue, or Table triggers locally.
@@ -100,17 +100,17 @@ here is the generated corresponding `function.json` by the [azure-functions-mave
100
100
101
101
## JDK runtime availability and support
102
102
103
-
Download and use the [Azul Zulu for Azure](https://assets.azul.com/files/Zulu-for-Azure-FAQ.pdf) JDKs from [Azul Systems](https://www.azul.com/downloads/azure-only/zulu/) for local development of Java function apps. JDKs are available for Windows, Linux, and macOS and [Azure support](https://support.microsoft.com/en-us/help/4026305/sql-contact-microsoft-azure-support) is available for issues encountered during development with a [qualified support plan](https://azure.microsoft.com/support/plans/).
103
+
Download and use the [Azul Zulu for Azure](https://assets.azul.com/files/Zulu-for-Azure-FAQ.pdf) JDKs from [Azul Systems](https://www.azul.com/downloads/azure-only/zulu/) for local development of Java function apps. JDKs are available for Windows, Linux, and macOS. [Azure support](https://support.microsoft.com/en-us/help/4026305/sql-contact-microsoft-azure-support) is available with a [qualified support plan](https://azure.microsoft.com/support/plans/).
104
104
105
105
## Third-party libraries
106
106
107
107
Azure Functions supports the use of third-party libraries. By default, all dependencies specified in your project `pom.xml` file will be automatically bundled during the [`mvn package`](https://github.com/Microsoft/azure-maven-plugins/blob/master/azure-functions-maven-plugin/README.md#azure-functionspackage) goal. For libraries not specified as dependencies in the `pom.xml` file, place them in a `lib` directory in the function's root directory. Dependencies placed in the `lib` directory will be added to the system class loader at runtime.
108
108
109
-
The `com.microsoft.azure.functions:azure-functions-java-library` dependency is provided on the classpath by default, and does not need to be included in the `lib` directory. Also, depedencies listed [here](https://github.com/Azure/azure-functions-java-worker/wiki/Azure-Java-Functions-Worker-Dependencies) are added to the classpath by [azure-functions-java-worker](https://github.com/Azure/azure-functions-java-worker).
109
+
The `com.microsoft.azure.functions:azure-functions-java-library` dependency is provided on the classpath by default, and does not need to be included in the `lib` directory. Also, dependencies listed [here](https://github.com/Azure/azure-functions-java-worker/wiki/Azure-Java-Functions-Worker-Dependencies) are added to the classpath by [azure-functions-java-worker](https://github.com/Azure/azure-functions-java-worker).
110
110
111
111
## Data type support
112
112
113
-
You can use Plain old Java objects (POJOs), primitive dataTypes such as String, Ineteger or types defined in `azure-functions-java-library`package for input and output bindings. The Azure Functions runtime attempts convert the input received into the type requested by your code.
113
+
You can use Plain old Java objects (POJOs), types defined in `azure-functions-java-library`or primitive dataTypes such as String, Integer to bind to input/output bindings. The Azure Functions runtime attempts convert the input received into the type requested by your code.
114
114
115
115
### Plain old Java objects (POJOs)
116
116
@@ -187,7 +187,7 @@ public class Function {
187
187
}
188
188
```
189
189
190
-
This function is invoked with a HTTP request. HTTP request payload is passed as a `String` for the argument `inputReq`; and one entry is retrieved from the Azure Table Storage and is passed as `TestInputData` to the argument `inputData`.
190
+
This function is invoked with an HTTP request. HTTP request payload is passed as a `String` for the argument `inputReq`; and one entry is retrieved from the Azure Table Storage and is passed as `TestInputData` to the argument `inputData`.
191
191
192
192
To receive a batch of inputs bind to `String[]`, `POJO[]`, `List<String>` or `List<POJO>`
193
193
@@ -206,7 +206,7 @@ To receive a batch of inputs bind to `String[]`, `POJO[]`, `List<String>` or `Li
206
206
207
207
```
208
208
209
-
This function gets triggered whenever there is new data in the configured eventhub. As the `cardinality` is set to `MANY`, function receives a batch of messages from event hub. EventData from eventhub gets converted to `TestEventData` for the function execution.
209
+
This function gets triggered whenever there is new data in the configured event hub. As the `cardinality` is set to `MANY`, function receives a batch of messages from event hub. EventData from event hub gets converted to `TestEventData` for the function execution.
210
210
211
211
### Example Output binding
212
212
@@ -263,7 +263,7 @@ To send multiple output values, use `OutputBinding<T>` defined in the `azure-fun
263
263
}
264
264
```
265
265
266
-
Above function is invoked on a HttpRequest and writes multiple values to the Azure Queue
266
+
Above function is invoked on an HttpRequest and writes multiple values to the Azure Queue
267
267
268
268
## HttpRequestMessage and HttpResponseMessage
269
269
@@ -317,7 +317,11 @@ In the example above, the `queryValue` is bound to query string parameter `name`
317
317
318
318
## Execution context
319
319
320
-
`ExecutionContext` type defined in the `azure-functions-java-library` package contains Logger that can be used to write logs from function code and helper method to get the function invocation id
320
+
`ExecutionContext` defined in the `azure-functions-java-library` contains helper methods to communicate with the functions runtime.
321
+
322
+
### Logger
323
+
324
+
Use `getLogger` defined in `ExecutionContext` to write logs from function code.
321
325
322
326
Example:
323
327
@@ -338,7 +342,9 @@ public class Function {
338
342
339
343
## View logs and trace
340
344
341
-
You can use the Azure CLI to stream Java standard out and error logging as well as other application logging. First, Configure your Function application to write application logging using the Azure CLI:
345
+
You can use the Azure CLI to stream Java standard out and error logging as well as other application logging.
346
+
347
+
Configure your Function application to write application logging using the Azure CLI:
342
348
343
349
```azurecli-interactive
344
350
az webapp log config --name functionname --resource-group myResourceGroup --application-logging true
@@ -361,7 +367,7 @@ You must have enabled file system logging in the Azure Portal or Azure CLI befor
361
367
362
368
## Environment variables
363
369
364
-
In Functions, [app settings](https://docs.microsoft.com/en-us/azure/azure-functions/functions-app-settings), such as service connection strings, are exposed as environment variables during execution. You can access these settings using, `System.getenv("AzureWebJobsStorage")`
370
+
In Functions, [app settings](https://docs.microsoft.com/en-us/azure/azure-functions/functions-app-settings), such as service connection strings, are exposed as environment variables during execution. You can access these settings using, `System.getenv("AzureWebJobsStorage")`
0 commit comments