Skip to content

Commit 78076e6

Browse files
authored
Merge pull request #31339 from andxu/andxu-functions-java
Update the sample code which is out of date for azure functions using java.
2 parents 71745e8 + c5eaa89 commit 78076e6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

articles/azure-functions/functions-create-first-java-maven.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public class Function {
8585
* 2. curl {your host}/api/hello?name=HTTP%20Query
8686
*/
8787
@FunctionName("hello")
88-
public HttpResponseMessage<String> hello(
89-
@HttpTrigger(name = "req", methods = {"get", "post"}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
88+
public HttpResponseMessage run(
89+
@HttpTrigger(name = "req", methods = { HttpMethod.GET, HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
9090
final ExecutionContext context) {
9191
context.getLogger().info("Java HTTP trigger processed a request.");
9292

@@ -95,9 +95,9 @@ public class Function {
9595
String name = request.getBody().orElse(query);
9696

9797
if (name == null) {
98-
return request.createResponse(400, "Please pass a name on the query string or in the request body");
98+
return request.createResponseBuilder(HttpStatus.BAD_REQUEST).body("Please pass a name on the query string or in the request body").build();
9999
} else {
100-
return request.createResponse(200, "Hello, " + name);
100+
return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build();
101101
}
102102
}
103103
}
@@ -135,7 +135,7 @@ Http Functions:
135135
Trigger the function from the command line using curl in a new terminal window:
136136

137137
```
138-
curl -w '\n' -d LocalFunction http://localhost:7071/api/hello
138+
curl -w "\n" http://localhost:7071/api/hello -d LocalFunction
139139
```
140140

141141
```Output
@@ -177,7 +177,7 @@ Test the function app running on Azure using `cURL`. You'll need to change the U
177177
> Make sure you set the **Access rights** to `Anonymous`. When you choose the default level of `Function`, you are required to present the [function key](../azure-functions/functions-bindings-http-webhook.md#authorization-keys) in requests to access your function endpoint.
178178
179179
```
180-
curl -w '\n' https://fabrikam-function-20170920120101928.azurewebsites.net/api/hello -d AzureFunctions
180+
curl -w "\n" https://fabrikam-function-20170920120101928.azurewebsites.net/api/hello -d AzureFunctions
181181
```
182182

183183
```Output

0 commit comments

Comments
 (0)