Add azure function-catalog support docs
This commit is contained in:
@@ -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 <<spring-cloud-function.adoc#function.catalog,Function Catalog>> 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 <<spring-cloud-function.adoc#function.catalog,Function Catalog>> 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 <<star-class-configuration, main class configuration>>.
|
||||
<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 <<spring-cloud-function.adoc#function.catalog,Function Catalog>> 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<Message<String>, 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)]
|
||||
- <<spring-cloud-function.adoc#,Spring Cloud Function - Reference Guide>>
|
||||
- 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!:
|
||||
@@ -24,6 +24,7 @@ include::getting-started.adoc[]
|
||||
|
||||
== Programming model
|
||||
|
||||
[[function.catalog]]
|
||||
|
||||
=== Function Catalog and Flexible Function Signatures
|
||||
|
||||
|
||||
Reference in New Issue
Block a user