Skip to content

Commit 9f8853d

Browse files
committed
higher score
1 parent af8c2ae commit 9f8853d

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

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

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ms.author: routlaw
2121

2222
The concepts of [triggers and bindings](functions-triggers-bindings.md) are fundamental to Azure Functions. Triggers start the execution of your code. Bindings give you a way to pass data to and return data from a function, without having to write custom data access code.
2323

24-
A function should be a stateless method to process input and produce output. Although you are allowed to write instance methods, your function must not depend on any instance fields of the class. All the function methods should be `public` and method with annotation @FunctionName must be unique as method name defines the entry for a function.
24+
A function should be a stateless method to process input and produce output. Your function cannot depend on any instance fields of the class. All the function methods should be `public` and method with annotation @FunctionName must be unique as method name defines the entry for a function.
2525

2626
## Folder structure
2727

@@ -110,42 +110,29 @@ The `com.microsoft.azure.functions:azure-functions-java-library` dependency is p
110110

111111
## Data type support
112112

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.
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.
114114

115115
### Plain old Java objects (POJOs)
116116

117117
For converting input data to POJO, [azure-functions-java-worker](https://github.com/Azure/azure-functions-java-worker) uses [gson](https://github.com/google/gson) library. POJO types used as inputs to functions must the same `public` access modifier as the function methods they are being used in.
118118

119119
### Binary data
120120

121-
Binary data is represented as a `byte[]` in your Azure functions code. Bind binary inputs or outputs to your functions by setting the `dataType` field in your function.json to `binary`:
122-
123-
```json
124-
{
125-
"scriptFile": "azure-functions-example.jar",
126-
"entryPoint": "com.example.Function.echo",
127-
"bindings": [
128-
{
129-
"type": "blob",
130-
"name": "content",
131-
"direction": "in",
132-
"dataType": "binary",
133-
"path": "container/myfile.bin",
134-
"connection": "ExampleStorageAccount"
135-
},
136-
]
137-
}
138-
```
139-
140-
Then use it in your function code:
121+
Bind binary inputs or outputs to `byte[]` by setting the `dataType` field in your function.json to `binary`:
141122

142123
```java
143-
// Class definition and imports are omitted here
144-
public static String echoLength(byte[] content) {
145-
}
124+
@FunctionName("BlobTrigger")
125+
@StorageAccount("AzureWebJobsStorage")
126+
public void blobTrigger(
127+
@BlobTrigger(name = "content", path = "myblob/{fileName}", dataType = "binary") byte[] content,
128+
@BindingName("fileName") String fileName,
129+
final ExecutionContext context
130+
) {
131+
context.getLogger().info("Java Blob trigger function processed a blob.\n Name: " + fileName + "\n Size: " + content.length + " Bytes");
132+
}
146133
```
147134

148-
Empty input values could be `null` as your functions argument, but a recommended way to deal with potential empty values is to use `Optional<T>`.
135+
Use `Optional<T>` for if null values are expected
149136

150137
## Bindings
151138

0 commit comments

Comments
 (0)