diff --git a/docs/modules/ROOT/pages/adapters/azure-intro.adoc b/docs/modules/ROOT/pages/adapters/azure-intro.adoc index b44e77336..c8d0d8610 100644 --- a/docs/modules/ROOT/pages/adapters/azure-intro.adoc +++ b/docs/modules/ROOT/pages/adapters/azure-intro.adoc @@ -74,15 +74,19 @@ public class MyAzureFunction { @FunctionName("spring") // <3> public String plainBean( // <4> - @HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, - ExecutionContext context) { + @HttpTrigger(name = "req", + methods = { HttpMethod.POST }, + authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, + ExecutionContext context) { return this.uppercase.apply(request.getBody().get()); } @FunctionName("scf") // <3> public String springCloudFunction( // <5> - @HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, + @HttpTrigger(name = "req", + methods = { HttpMethod.POST }, + authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, ExecutionContext context) { // Use SCF composition. Composed functions are not just spring beans but SCF such. @@ -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> request, - ExecutionContext context) { + @HttpTrigger(name = "req", + methods = { HttpMethod.POST }, + authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, + ExecutionContext context) { Message message = (Message) AzureFunctionUtil.enhanceInputIfNecessary(request.getBody().get(), context); // <1> diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-azure/src/test/java/org/springframework/cloud/function/adapter/azure/injector/AzureFunctionInstanceInjectorTest.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-azure/src/test/java/org/springframework/cloud/function/adapter/azure/injector/AzureFunctionInstanceInjectorTest.java index 7a52dee43..11dfa8c48 100644 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-azure/src/test/java/org/springframework/cloud/function/adapter/azure/injector/AzureFunctionInstanceInjectorTest.java +++ b/spring-cloud-function-adapters/spring-cloud-function-adapter-azure/src/test/java/org/springframework/cloud/function/adapter/azure/injector/AzureFunctionInstanceInjectorTest.java @@ -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; @@ -80,7 +81,8 @@ public static class MyAzureFunction { @FunctionName("hello") public String execute( - @HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, + @HttpTrigger(name = "req", methods = { HttpMethod.GET, + HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, ExecutionContext context) { Message enhancedRequest = (Message) AzureFunctionUtil.enhanceInputIfNecessary( diff --git a/spring-cloud-function-samples/function-sample-azure-http-trigger/pom.xml b/spring-cloud-function-samples/function-sample-azure-http-trigger/pom.xml index ca3acdea9..2f312239a 100644 --- a/spring-cloud-function-samples/function-sample-azure-http-trigger/pom.xml +++ b/spring-cloud-function-samples/function-sample-azure-http-trigger/pom.xml @@ -24,7 +24,7 @@ com.example.azure.di.httptriggerdemo.HttpTriggerDemoApplication - 1.22.0 + 1.28.0 spring-cloud-function-samples westus java-functions-group @@ -69,6 +69,7 @@ ${functionPricingTier} ${project.basedir}/src/main/resources/host.json + ${project.basedir}/src/main/resources/local.settings.json linux diff --git a/spring-cloud-function-samples/function-sample-azure-http-trigger/src/main/java/com/example/azure/di/httptriggerdemo/MyAzureFunction.java b/spring-cloud-function-samples/function-sample-azure-http-trigger/src/main/java/com/example/azure/di/httptriggerdemo/MyAzureFunction.java index 6838aa7d7..62b20ca3a 100644 --- a/spring-cloud-function-samples/function-sample-azure-http-trigger/src/main/java/com/example/azure/di/httptriggerdemo/MyAzureFunction.java +++ b/spring-cloud-function-samples/function-sample-azure-http-trigger/src/main/java/com/example/azure/di/httptriggerdemo/MyAzureFunction.java @@ -53,7 +53,8 @@ public class MyAzureFunction { @FunctionName("bean") public String plainBeans( - @HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, + @HttpTrigger(name = "req", methods = { + HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, ExecutionContext context) { return echo.andThen(uppercase).apply(request.getBody().get()); @@ -61,7 +62,8 @@ public String plainBeans( @FunctionName("scf") public String springCloudFunction( - @HttpTrigger(name = "req", authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, + @HttpTrigger(name = "req", methods = { + HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, ExecutionContext context) { // Use SCF composition. Composed functions are not just spring beans but SCF such. diff --git a/spring-cloud-function-samples/function-sample-azure-http-trigger/src/main/resources/host.json b/spring-cloud-function-samples/function-sample-azure-http-trigger/src/main/resources/host.json index 10d0c0748..ccafcc17c 100644 --- a/spring-cloud-function-samples/function-sample-azure-http-trigger/src/main/resources/host.json +++ b/spring-cloud-function-samples/function-sample-azure-http-trigger/src/main/resources/host.json @@ -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" } \ No newline at end of file