From b438c6d01446f0f070fa58a8ad5df2a77890626b Mon Sep 17 00:00:00 2001 From: Christian Tzolov Date: Tue, 25 Jul 2023 13:27:58 +0200 Subject: [PATCH] Add azure function-catalog support docs --- .../main/asciidoc/adapters/azure-intro.adoc | 26 ++++++++++++++++--- .../main/asciidoc/spring-cloud-function.adoc | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/docs/src/main/asciidoc/adapters/azure-intro.adoc b/docs/src/main/asciidoc/adapters/azure-intro.adoc index 308d04e4c..59ceca215 100644 --- a/docs/src/main/asciidoc/adapters/azure-intro.adoc +++ b/docs/src/main/asciidoc/adapters/azure-intro.adoc @@ -51,10 +51,11 @@ dependencies { NOTE: version `4.0.0+` is required. Having the adapter on the classpath activates the Azure Java Worker integration. -=== Function Implementation +[[azure.development.guidelines]] +=== Development Guidelines Use the `@Component` (or `@Service`) annotation to turn any exiting Azure Function class (e.g. with `@FunctionName` handlers) into a Spring component. -Then you can auto-wire the required dependencies (or the https://docs.spring.io/spring-cloud-function/docs/current/reference/html/spring-cloud-function.html#_function_catalog_and_flexible_function_signatures[FunctionCatalog] for Spring Cloud Function composition) and use those inside the Azure function handlers. +Then you can auto-wire the required dependencies (or the <> for Spring Cloud Function composition) and use those inside the Azure function handlers. [source,java] ---- @@ -95,7 +96,7 @@ When invoked by a trigger (such as `@HttpTrigger`), functions process that trigg <4> The `plainBean` method handler is mapped to an Azure function that uses of the auto-wired `uppercase` spring bean to compute the result. It demonstrates how to use "plain" Spring components in your Azure handlers. <5> The `springCloudFunction` method handler is mapped to another Azure function, that uses the auto-wired `FunctionCatalog` instance to compute the result. -<6> Shows how to leverage the Spring Cloud Function https://docs.spring.io/spring-cloud-function/docs/current/reference/html/spring-cloud-function.html#_function_catalog_and_flexible_function_signatures[FunctionCatalog] composition API. +<6> Shows how to leverage the Spring Cloud Function <> composition API. TIP: Use the Java annotations included in the https://learn.microsoft.com/en-us/java/api/com.microsoft.azure.functions.annotation?view=azure-java-stable[com.microsoft.azure.functions.annotation.*] package to bind input and outputs to your methods. @@ -126,6 +127,16 @@ public class HttpTriggerDemoApplication { <1> The `@SpringBootApplication` annotated class is used as a `Main-Class` as explained in <>. <2> Functions auto-wired and used in the Azure function handlers. +==== Function Catalog + +The Spring Cloud Function supports a range of type signatures for user-defined functions, while providing a consistent execution model. +For this it uses the <> to transform all user defined functions into a canonical representation. + +The Azure adapter can auto-wire any Spring component, such as the `uppercase` above. +But those are treated as plain Java class instances, not as a canonical Spring Cloud Functions! + +To leverage Spring Cloud Function and have access to the canonical function representations, you need to auto-wire the `FunctionCatalog` and use it in your handler, like the `functionCatalog` instance the `springCloudFunction()` handler above. + ==== Accessing Azure ExecutionContext Some time there is a need to access the target execution context provided by the Azure runtime in the form of `com.microsoft.azure.functions.ExecutionContext`. @@ -164,6 +175,7 @@ public Function, String> uppercase(JsonMapper mapper) { ---- <1> Retrieve the ExecutionContext instance from the header. + [[azure.configuration]] === Configuration @@ -510,4 +522,12 @@ WARNING: The legacy `FunctionInvoker` programming model is deprecated and will n For additional documentation and samples about the Function Integration approach follow the https://github.com/spring-cloud/spring-cloud-function/tree/main/spring-cloud-function-samples/function-sample-azure/[azure-sample] README and code. +== Relevant Links + +- https://learn.microsoft.com/en-us/azure/developer/java/spring-framework/getting-started-with-spring-cloud-function-in-azure[Spring Cloud Function in Azure] +- https://spring.io/blog/2023/02/24/spring-cloud-function-for-azure-function[Spring Cloud Function for Azure Function (blog)] +- <> +- https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-java?tabs=bash%2Cconsumption[Azure Functions Java developer guide] +- https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference?tabs=blob[Azure Functions developer guide] + :sectnums!: \ No newline at end of file diff --git a/docs/src/main/asciidoc/spring-cloud-function.adoc b/docs/src/main/asciidoc/spring-cloud-function.adoc index b259c6fa5..7eea6e5fc 100644 --- a/docs/src/main/asciidoc/spring-cloud-function.adoc +++ b/docs/src/main/asciidoc/spring-cloud-function.adoc @@ -24,6 +24,7 @@ include::getting-started.adoc[] == Programming model +[[function.catalog]] === Function Catalog and Flexible Function Signatures