Reputation: 3851
Is it possible to pass command line arguments to a Spring boot app on Azure via the web.config file? Our app is up and running but we need to set the:
--spring.profiles.active=local
at startup.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="ack=t-Djava.net.preferIPv4Strue -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\myjar-0.0.1.jar"">
</httpPlatform>
</system.webServer>
</configuration>
Upvotes: 2
Views: 2517
Reputation: 245
Configuration-> Application Settings, I've simply added:
After that, Springboot could load: application-prod.properties
Upvotes: 2
Reputation: 3851
I got a response from Microsoft and they had two ways:
Add "environmentVariables" block to the xml above:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\AssetCommander-0.0.1.jar"">
<environmentVariables>
<environmentVariable name="JAVA_OPTS" value="-Dspring.profiles.active=dev" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
[
3, Actually, neither of those worked for us. We had to do this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dspring.profiles.active=%spring.profiles.active% -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\AssetCommander-0.0.1.jar"">
</httpPlatform>
</system.webServer>
</configuration>
AND #2 above.
Upvotes: 5