Skip to content

Commit

Permalink
Fix the http trigger signatures in tests, samples and docs. Upgrade t…
Browse files Browse the repository at this point in the history
…he azure maven version

Resolves #1088
  • Loading branch information
tzolov authored and olegz committed Nov 30, 2023
1 parent c3cb561 commit 9ceb4f6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
16 changes: 11 additions & 5 deletions docs/modules/ROOT/pages/adapters/azure-intro.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,19 @@ public class MyAzureFunction {
@FunctionName("spring") // <3>
public String plainBean( // <4>
@HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
ExecutionContext context) {
@HttpTrigger(name = "req",
methods = { HttpMethod.POST },
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
ExecutionContext context) {
return this.uppercase.apply(request.getBody().get());
}
@FunctionName("scf") // <3>
public String springCloudFunction( // <5>
@HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
@HttpTrigger(name = "req",
methods = { HttpMethod.POST },
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
ExecutionContext context) {
// Use SCF composition. Composed functions are not just spring beans but SCF such.
Expand Down Expand Up @@ -154,8 +158,10 @@ For that purpose the `AzureFunctionUtil.enhanceInputIfNecessary` allow you to ad
----
@FunctionName("myfunction")
public String execute(
@HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
ExecutionContext context) {
@HttpTrigger(name = "req",
methods = { HttpMethod.POST },
authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
ExecutionContext context) {
Message message =
(Message) AzureFunctionUtil.enhanceInputIfNecessary(request.getBody().get(), context); // <1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.function.Function;

import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.HttpMethod;
import com.microsoft.azure.functions.HttpRequestMessage;
import com.microsoft.azure.functions.annotation.AuthorizationLevel;
import com.microsoft.azure.functions.annotation.FunctionName;
Expand Down Expand Up @@ -80,7 +81,8 @@ public static class MyAzureFunction {

@FunctionName("hello")
public String execute(
@HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
@HttpTrigger(name = "req", methods = { HttpMethod.GET,
HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
ExecutionContext context) {

Message<String> enhancedRequest = (Message<String>) AzureFunctionUtil.enhanceInputIfNecessary(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<start-class>com.example.azure.di.httptriggerdemo.HttpTriggerDemoApplication</start-class>

<!-- AZURE FUNCTION CONFIG -->
<azure.functions.maven.plugin.version>1.22.0</azure.functions.maven.plugin.version>
<azure.functions.maven.plugin.version>1.28.0</azure.functions.maven.plugin.version>
<functionAppName>spring-cloud-function-samples</functionAppName>
<functionAppRegion>westus</functionAppRegion>
<functionResourceGroup>java-functions-group</functionResourceGroup>
Expand Down Expand Up @@ -69,6 +69,7 @@
<pricingTier>${functionPricingTier}</pricingTier>

<hostJson>${project.basedir}/src/main/resources/host.json</hostJson>
<localSettingsJson>${project.basedir}/src/main/resources/local.settings.json</localSettingsJson>

<runtime>
<os>linux</os>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ public class MyAzureFunction {

@FunctionName("bean")
public String plainBeans(
@HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
@HttpTrigger(name = "req", methods = {
HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
ExecutionContext context) {

return echo.andThen(uppercase).apply(request.getBody().get());
}

@FunctionName("scf")
public String springCloudFunction(
@HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
@HttpTrigger(name = "req", methods = {
HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
ExecutionContext context) {

// Use SCF composition. Composed functions are not just spring beans but SCF such.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.*, 4.0.0)"
}
"version": "[4.*, 5.2.0)"
},
"functionTimeout": "00:10:00"
}

0 comments on commit 9ceb4f6

Please sign in to comment.