guntarion
guntarion

Reputation: 101

How to deploy jHipster on Azure App Service, I got 500 request timed out

This guideline provided by Microsoft is for SpringBoot App

https://learn.microsoft.com/en-us/azure/app-service/app-service-deploy-spring-boot-web-app-on-azure

which is essentially:

  1. Create an Azure web app for use with Java
  2. Specify the Java version
  3. Obtain FTP deployment credential
  4. Upload your SpringBoot .JAR along with provided web.config
  5. Restart the web app via Azure portal
  6. The app works!

Instead of .jar, jHipster is producing .war file. Since it is essentially the same (i.e. it can be executed with java -jar), I was hoping the steps would also works for .war.

I've uploaded:

  1. the .war file
  2. the .war.original file
  3. web.config

This is the aforementioned web.config. Please note I've renamed the -jar into -war

<?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% -war &quot;%HOME%\site\wwwroot\gmbgenpro-0.0.1-SNAPSHOT.war&quot;">
    </httpPlatform>
  </system.webServer>
</configuration>

The app is loading so long that I got the 500 request timed out.

EDIT: I've enabled stdout in the web.config and I got the following from the log files:

Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: -war

So it seems I could not use the -war parameter, and I don't know what to do.

Upvotes: 2

Views: 1069

Answers (1)

Bruno Borges
Bruno Borges

Reputation: 851

To deploy your JHipster project as a WAR file, make sure you build it with spring-boot.repackage.skip option enabled. This will skip building an executable WAR file and simply package the WAR file normally under ${finalName}.war. This way you can deploy your application to a web runtime on Azure automatically configured for you.

To proceed with the deployment, follow these steps:

  1. Add the following Maven Plugin configuration to your main element of your pom.xml:

     <plugin>
         <groupId>com.microsoft.azure</groupId>
         <artifactId>azure-webapp-maven-plugin</artifactId>
         <!-- check Maven Central for the latest version -->
         <version>1.3.0</version>
         <configuration>
             <resourceGroup>your-resource-group</resourceGroup>
             <appName>your-app-name</appName>
             <linuxRuntime>tomcat 9.0-jre8</linuxRuntime>-->
         </configuration>
     </plugin>
    
  2. Build your project with the following command, and adjust your profile accordingly:

    ./mvnw clean package -Pdev -Dspring-boot.repackage.skip=true
    
  3. Deploy your application:

    ./mvnw azure-webapp:deploy
    

For up-to-date information about the Maven Plugin for Azure App Service, check the documentation.

Upvotes: 1

Related Questions