3

I have a java-application (standard springboot from default tutorial: https://spring.io/guides/gs/spring-boot-for-azure/ ) that I "successfuly" deploy to my WebApp (created during deployment) via Eclipse/maven plugin azure-webapp:deploy

Once deployed, files are inside the WebApp, I can see them. If start-up is successful I do get running application, but if it is not - I do not know how to troubleshoot. I don't know where to find error logs, what caused the problem and as consequence, how to solve it.

as an example of how to make it fail, add this line:

throw new RuntimeException("Doomed to fail");

I tried enabling logs from "diagnostic logs tab" and expected to see them under LogFiles/Applications but that folder remains empty.

How do I troubleshoot java-application that fails to start in WebApps of Azure?

edit: additional example of Exception to troubleshoot:

public static void main(String[] args) {
    throw new RuntimeException("start failure #21");
    //SpringApplication.run(Application.class, args);
}
Andrii Plotnikov
  • 3,022
  • 4
  • 17
  • 37
  • OK, I was able to trick system and give me out logs, so now I can proceed, but I'll wait for an actual answer on how to properly do this + I might start bounty just for this because the way I did it is uncomfortable to work with – Andrii Plotnikov Feb 06 '19 at 15:31
  • upd 2: I switched to VM and started everything there since debugging there is so much simpler – Andrii Plotnikov Mar 27 '19 at 12:00

2 Answers2

0

It sounds like you followed the springboot tutorial Deploying a Spring Boot app to Azure to build the GitHub project microsoft/gs-spring-boot and deploy to Azure, but not works.

Here is my steps which I also followed the tutorial, but deployed via my own way.

  1. I created a directory SpringBoot on my local machine, and to do the commands cd SpringBoot and git clone https://github.com/microsoft/gs-spring-boot.
  2. Then, to build it via commands cd gs-spring-boot/complete and mvnw clean package

Note: I reviewed the sections of the tutorial under Create a sample Spring Boot web app which seems to do on Linux, but the web.config file in microsoft/gs-spring-boot/complete is ready to Azure WebApp for Windows. However, there is not any comments to describe the deployment target that be Azure WebApp for Windows or Linux.

  1. So I used my existing WebApp for Windows to test my deployment. I open my Kudu console in browser via the url https://<webapp name>.scm.azurewebsites.net/DebugConsole and drag the files complete/web.config and complete/target/gs-spring-boot-0.1.0.jar to site/wwwroot as the figure below. Then, I started my webapp, and it works fine.

enter image description here

enter image description here

Note: Please check the JAVA_HOME environment variable which has been configured on Azure via command echo %JAVA_HOME% as the figure below.

enter image description here

If not, you need to set Java runtime in the Application settings tab of Azure portal.

enter image description here

Or you can also configure the web.config file to replace the reference %JAVA_HOME% with an existing Java runtime installed in the path D:\Program Files\Java of Azure WebApp, as below.

<?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" -->
        <httpPlatform processPath="D:\Program Files\Java\jre1.8.0_181\bin\java.exe"
                      arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\gs-spring-boot-0.1.0.jar&quot;">
        </httpPlatform>
    </system.webServer>
</configuration>

enter image description here

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • the point of the question: I know how to make it work. But(!) I don't know how to troubleshoot in case it fails. Ok, in your case, imagine that in main method you have: throw new RuntimeException("start failure #21"); and so application fails at startup. How do you receive that message and know that it fails because of it ASSUMING you don't know that line of code is written there? – Andrii Plotnikov Feb 06 '19 at 10:38
0

I didn't manage to find logs in windows based machine, but If you enable logs on linux-based-machine you will see them in the "Diagnostic logs" output. There is a catch though.

There is 230 timeout. It will wait full "timeout" time, until producing logs in the log file, after which you can access them via log file or through "Diagnostic logs". Make sure to enable logging before you start application. This applies to linux based machine, I don't know if it can apply to windows based machine.

Then it waits for an answer trigger. Answer trigger, as it turns out, is a phrase in console output "Application is started in X seconds". I increased the timeout to 500 seconds, because although it starts in 60 seconds on my local machine, it takes 430 seconds on remote-linux-based machine of Microsoft Azure*

Second, I changed the name of my main class from "GameStart" to "Application" and after that it actually caught the trigger. After that the application started. Nowhere in manuals did I find the "until timeout - no logs" and "trigger phrase" clauses mentioned.

ps: For reference, it took me 20 to upload application, 5 minutes to start it. I was using centralUS server, cuz centralEU did not work out for me, as it was even longer, although I'm in central EU myself

-

*using test account. It might happen that on payed account number are either different or similar.

Andrii Plotnikov
  • 3,022
  • 4
  • 17
  • 37