Remote debugging of Java applications in Azure Web Apps

tl;dr

https://github.com/Azure/azure-websites-java-remote-debugging

Just do the work here.

procedure

Enable WebSocket in WebApps settings

Open the WebApp application settings from the Azure portal and leave "WebSockets" turned on.

2018-04-05-21-05-49.png

This setting is required because it communicates with the remote via WebSocket when debugging.

Create site \ wwwroot \ web.config on the App Service.

It's easy to access and create kudu, which is dying behind the WebApp.

kudu is roughly the software that supports AppService behind the scenes, taking care of deployment control, WebJobs operation, etc., and using it from a browser that is convenient for development. We also provide a console that you can do.

--Open your browser and go to https://YOURAPP.scm.azurewebsites.net/DebugConsole -(* YOURAPP is the name when creating the WebApp resource. It is good to remember that scm is just inserted between the public URLs.) --Move to site wwwroot --Create a web.config file with" New File "from the[+]icon. --The part of % programfiles (x86)% is for 32bit and different for 64bit. (32bit for cheap plans such as Free) --ʻApache-tomcat-8.0.46` part changes depending on the version of tomcat.

web.config


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httppPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
        </handlers>
        
        <httpPlatform processPath="%programfiles(x86)%\apache-tomcat-8.0.46\bin\startup.bat">
            <environmentVariables>
                <environmentVariable name="CATALINA_HOME" value="%programfiles(x86)%\apache-tomcat-8.0.46"/>
                <environmentVariable name="JAVA_OPTS" value="-Djava.net.preferIPv4Stack=true -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=127.0.0.1:%HTTP_PLATFORM_DEBUG_PORT%"/>
                <environmentVariable name="CATALINA_OPTS" value="-Dport.http=%HTTP_PLATFORM_PORT%"/>
            </environmentVariables>
        </httpPlatform>
    </system.webServer>
</configuration>

Application restart

Reboot from the portal.

After restarting, access once and keep the Java process running. Can be confirmed with Process Explorer on kudu

This is the end of the work on the WebApp side.

Launching the DebugSession client

From here, work on the local machine.

Download the DebugSession client from https://github.com/Azure/azure-websites-java-remote-debugging/releases.

Start by giving the following arguments to DebugSessin.bat in bin. Set the environment variable JAVA_HOME.

DebugSession.bat ^
  --auto ^
  -p 8000 ^
  -s YOURAPP.scm.azurewebsites.net ^
  -u $YOURAPP ^
  -w ****

Info: Waiting for debugger to connect on 8000 ...

If it says ..., you're ready to go.

For connection information (Publish URL / User / Pass), if you use Azure CLI, you can use the value of MS Deploy obtained around ʻaz webapp deployment list-publishing-profiles ...`.

Launch the debugger

After that, remote debugging can be performed by connecting to the DebugSession client (localhost: 8080) from a debugger on Eclipse.

However, since it is remote, the operation is sluggish. (Maybe because it was a free plan.)

Recommended Posts

Remote debugging of Java applications in Azure Web Apps
Creating Java Web Applications to Azure Web Apps
Role of JSP in Web application [Java]
Try remote debugging of Java with Remote Containers in Visual Studio Code Insiders
Azure functions in java
Security in web applications
The part I was addicted to in "Introduction to Ajax in Java Web Applications" of NetBeans
Create Azure Functions in Java
Implementation of gzip in java
Implementation of tri-tree in Java
Run Java application in Azure Batch
Automatically deploy Web applications developed in Java using Jenkins [Tomcat application]
List of members added in Java 9
List of types added in Java 9
Implementation of like function in Java
Remote debugging of the Cognos SDK
Implementation of DBlayer in Java (RDB, MySQL)
War deploy to Azure Web Apps (maven)
Building Java Web Applications on Windows Server 2016
The story of writing Java in Emacs
Discrimination of Enums in Java 7 and above
Introduction to Java Web Apps Performance Troubleshooting
The story of low-level string comparison in Java
The story of making ordinary Othello in Java
About the idea of anonymous classes in Java
Deploy Java web app to Azure with maven
How to display a web page in Java
Implementation of digit grouping in flea market apps
The story of learning Java in the first programming
Measure the size of a folder in Java
[Java] Use of final in local variable declaration
Feel the passage of time even in Java
Let's create a super-simple web framework in Java
Basics of threads and Callable in Java [Beginner]
A quick review of Java learned in class
Method name of method chain in Java Builder + α
Import files of the same hierarchy in Java
Why use setters/getters instead of public/private in Java