You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/main/asciidoc/adapters/azure-intro.adoc
+23-3Lines changed: 23 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,10 +51,11 @@ dependencies {
51
51
52
52
NOTE: version `4.0.0+` is required. Having the adapter on the classpath activates the Azure Java Worker integration.
53
53
54
-
=== Function Implementation
54
+
[[azure.development.guidelines]]
55
+
=== Development Guidelines
55
56
56
57
Use the `@Component` (or `@Service`) annotation to turn any exiting Azure Function class (e.g. with `@FunctionName` handlers) into a Spring component.
57
-
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.
58
+
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.
58
59
59
60
[source,java]
60
61
----
@@ -95,7 +96,7 @@ When invoked by a trigger (such as `@HttpTrigger`), functions process that trigg
95
96
<4> The `plainBean` method handler is mapped to an Azure function that uses of the auto-wired `uppercase` spring bean to compute the result.
96
97
It demonstrates how to use "plain" Spring components in your Azure handlers.
97
98
<5> The `springCloudFunction` method handler is mapped to another Azure function, that uses the auto-wired `FunctionCatalog` instance to compute the result.
98
-
<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.
99
+
<6> Shows how to leverage the Spring Cloud Function <<spring-cloud-function.adoc#function.catalog,Function Catalog>> composition API.
99
100
100
101
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.
101
102
@@ -126,6 +127,16 @@ public class HttpTriggerDemoApplication {
126
127
<1> The `@SpringBootApplication` annotated class is used as a `Main-Class` as explained in <<star-class-configuration, main class configuration>>.
127
128
<2> Functions auto-wired and used in the Azure function handlers.
128
129
130
+
==== Function Catalog
131
+
132
+
The Spring Cloud Function supports a range of type signatures for user-defined functions, while providing a consistent execution model.
133
+
For this it uses the <<spring-cloud-function.adoc#function.catalog,Function Catalog>> to transform all user defined functions into a canonical representation.
134
+
135
+
The Azure adapter can auto-wire any Spring component, such as the `uppercase` above.
136
+
But those are treated as plain Java class instances, not as a canonical Spring Cloud Functions!
137
+
138
+
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.
139
+
129
140
==== Accessing Azure ExecutionContext
130
141
131
142
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) {
164
175
----
165
176
<1> Retrieve the ExecutionContext instance from the header.
166
177
178
+
167
179
[[azure.configuration]]
168
180
=== Configuration
169
181
@@ -510,4 +522,12 @@ WARNING: The legacy `FunctionInvoker` programming model is deprecated and will n
510
522
511
523
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.
512
524
525
+
== Relevant Links
526
+
527
+
- https://learn.microsoft.com/en-us/azure/developer/java/spring-framework/getting-started-with-spring-cloud-function-in-azure[Spring Cloud Function in Azure]
528
+
- https://spring.io/blog/2023/02/24/spring-cloud-function-for-azure-function[Spring Cloud Function for Azure Function (blog)]
529
+
- <<spring-cloud-function.adoc#,Spring Cloud Function - Reference Guide>>
0 commit comments