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
@@ -163,7 +165,7 @@ public Function<Message<String>, String> uppercase(JsonMapper mapper) {
163
165
164
166
In order to run Spring Cloud Function applications on Microsoft Azure, you have to use the Maven or Gradle plugins offered by Azure.
165
167
Later imposes a specific https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-java?tabs=bash%2Cconsumption#folder-structure[package archive structure] that interferes with the `standard` Spring Boot package jars.
166
-
The <<disable-spring-boot-layout,Disable Spring Boot Layout>> section below explains how to handle this.
168
+
The <<disable-spring-boot-plugin,Disable Spring Boot Plugin>> section below explains how to handle this.
167
169
You have to provide Azure specific configurations such as the `resourceGroup`, `appName` and other optional properties.
168
170
More information about the runtime configurations: https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-java?tabs=bash%2Cconsumption#java-versions[Java Versions], https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-java?tabs=bash%2Cconsumption#specify-the-deployment-os[Deployment OS].
169
171
@@ -249,17 +251,33 @@ azurefunctions {
249
251
The complete plugin documentation is available at the https://github.com/microsoft/azure-maven-plugins/tree/develop/azure-functions-maven-plugin[Azure Maven] and https://github.com/microsoft/azure-gradle-plugins/tree/master/azure-functions-gradle-plugin[Azure Gradle] repositories.
250
252
251
253
252
-
==== Disable Spring Boot Layout
254
+
==== Disable Spring Boot Plugin
253
255
254
-
The Azure Functions come with their own (non-Boot) execution runtime that imposes its own packaging format generated by the Azure's maven/gradle plugins.
255
-
Therefore we can't use the (standard) Spring Boot packaging.
256
-
You have to either disable the Spring-Boot plugin all together or opt for the https://github.com/dsyer/spring-boot-thin-launcher[spring-boot-thin-launcher] instead.
257
-
This https://github.com/spring-cloud/spring-cloud-function/blob/3bafcc59175fb61e323e393487d413441287a450/spring-cloud-function-samples/function-sample-azure-http-trigger/pom.xml#L97-L107[snipped] illustrates how to use the `spring-boot-thin-launcher` for Maven.
256
+
Expectedly, the Azure Functions run inside the Azure execution runtime, not inside the SpringBoot runtime!
257
+
Furthermore, Azure expects a specific packaging format, generated by the Azure Maven/Gradle plugins, that is not compatible with the default Spring Boot packaging.
258
258
259
-
==== Provide Main-Class
259
+
IMPORTANT: You have to either disable the SpringBoot Maven/Gradle plugin or use the https://github.com/dsyer/spring-boot-thin-launcher[Spring Boot Thin Launcher] as shown in this Maven snipped:
Next you must specify the `Start-Class` or `Main-Class` to point to your application main class.
276
+
==== Main-Class Configuration
277
+
278
+
Specify the `Main-Class`/`Start-Class` to point to your Spring application entry point, such as the <<HttpTriggerDemoApplication,HttpTriggerDemoApplication>> class in the example above.
279
+
280
+
You can use the Maven `start-class` property or set the `Main-Class` attribute of your `MANIFEST/META-INFO`:
Alternatively you can explicitly set the main class using the `MAIN_CLASS` environment variable.
288
-
289
-
For local runs, you can set the `MAIN_CLASS` in your the `local.settings.json`:
305
+
TIP: Alternatively you can use the `MAIN_CLASS` environment variable to set the class name explicitly.
306
+
For local runs, add the `MAIN_CLASS` variable to your `local.settings.json` file and for Azure portal deployment set the variable in the https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings?tabs=portal#get-started-in-the-azure-portal[App Settings].
290
307
291
-
[source,json]
292
-
----
293
-
{
294
-
"IsEncrypted": false,
295
-
"Values": {
296
-
... ,
297
-
"MAIN_CLASS": "YOUR-APP-MAIN-CLASS"
298
-
}
299
-
}
300
-
----
301
308
302
-
IMPORTANT: When not set via the `MAIN_CLASS` variable, the Azure adapter will try to retrieve the main class from the `MANIFEST/META-INFO` sections of all dependencies.
303
-
The first main class annotated with a `@SpringBootApplication` or `@SpringBootConfiguration` is selected.
309
+
IMPORTANT: If the `MAIN_CLASS` variable is not set, the Azure adapter lookups the `MANIFEST/META-INFO` attributes from the jars found on the classpath and selects the first `Main-Class:` annotated with either a `@SpringBootApplication` or `@SpringBootConfiguration` annotation.
0 commit comments