Skip to content

Set JAVA_OPTS for Windows App Services

Hanxiao Liu edited this page Nov 13, 2019 · 2 revisions

We removed web.config since azure-webapp-maven-plugin:1.8.0, and here is the new workaround to set JAVA_OPTS for Windows App Services

  1. Create new startup.cmd file in project folder as below
"%JAVA_HOME%\bin\java.exe" -noverify -Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% %JAVA_OPTS% -jar "%_WEBAPP_DIR%\app.jar"
  1. Add startup.cmd to <resources> configuration
<configuration>
    <schemaVersion>V2</schemaVersion>
    ...
    <deployment>
        <resources>
            <resource>
                <directory>${project.basedir}/target</directory>
                <includes>
                    <include>*.jar</include>
                </includes>
            </resource>
            <resource>
                <directory>${project.basedir}</directory>
                <includes>
                    <include>startup.cmd</include>
                </includes>
            </resource>
        </resources>
    </deployment>
</configuration>
  1. Add Java opts to <appSettings>
<configuration>
    <schemaVersion>V2</schemaVersion>
    ...
    <appSettings>
        <!--JVM OPTIONS -->
        <property>
            <name>JAVA_OPTS</name>
            <value>-Xms2048m -Xmx2048m</value>
        </property>
    </appSettings>
    ...
</configuration>
  1. Deploy with azure-webapp:deploy, and new java opts should works.
Clone this wiki locally