1

While deploying spring cloud function to azure using maven, I am trying to set "spring.profiles.active=dev" as below in pom.xml -

<plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-functions-maven-plugin</artifactId>
                <version>1.14.3</version>
                <configuration>
                    <resourceGroup>${functionResourceGroup}</resourceGroup>
                    <appName>${functionAppName}</appName>
                    <runtime>
                        <os>linux</os>
                    </runtime>
                    <region>southeastasia</region>
                    <appServicePlanName>appplan</appServicePlanName>
                    <disableAppInsights>true</disableAppInsights>
                    <appSettings>
                        <property>
                            <name>JAVA_OPTS</name>
                            <value>--spring.profiles.active=${spring.profiles.active}</value>
                        </property>
                        <property>
                            <name>WEBSITE_USE_PLACEHOLDER </name>
                            <value>0</value>
                        </property>
                    </appSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>package-functions</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

After running below two commands -

mvn clean package -Dspring.profiles.active=dev
mvn azure-functions:deploy -Dspring.profiles.active=dev

I can see that the function is successfully deployed to Azure and I can see the correct value of JAVA_OPTS being set under Function App >> Configuration >> Application Settings

But the profile is not being applied correctly as property values are not being read according the expected profile (dev).

Is this the correct way to set spring.profiles.active?

Jacob
  • 426
  • 3
  • 19

1 Answers1

0

It seems instead of JAVA_OPTS we should be using "languageWorkers__java__arguments" as the app setting name.

Jacob
  • 426
  • 3
  • 19
  • i found languageWorkers__node__arguments, but not languageWorkers__java__arguments in azure documentation. will this work for java spring boot applicaitons? – riaz7se Sep 08 '22 at 17:16
  • Yes this is working for a standalone java function app (function v3) whereby I can access these parameters using System.getProperty. I think it should work of spring boot as well as passing -Dspring.profiles.active seems to be recognized – Jacob Sep 14 '22 at 06:29