B4J Tutorial [server] Run a Server on Azure as an App Service

Discussion in 'B4J Tutorials' started by xulihang, Oct 16, 2018.

  1. xulihang

    xulihang Active Member Licensed User

    Since Azure supports Jetty, a B4J server app can also run on azure.

    1. Search jetty in the marketplace and create a web app service.

    [​IMG]

    2. Use git to clone the repository. You can find the link in "Properties".

    3. Place your .jar at someplace in the repository and edit web.config.

    change this:

    Code:
    arguments="-Djava.net.preferIPv4Stack=true
                                 -Djetty.port=%HTTP_PLATFORM_PORT%
                                 -Djetty.base="d:\home\site\wwwroot\bin\jetty-distribution-
    9.1.2.v20140210"
                                 -jar "d:\home\site\wwwroot\bin\jetty-distribution-
    9.1.2.v20140210\start.jar""
    to this:

    Code:
    arguments="-Djava.net.preferIPv4Stack=true
                                 -jar "d:\home\site\wwwroot\bin\start.jar"
                                 %HTTP_PLATFORM_PORT%
    "
    The server needs to set its port based on the argument. The b4j code:

    Code:
    Sub AppStart (Args() As String)
        
    Dim port As Int
        port=Args(
    0)
        srvr.Initialize(
    "srvr")
        srvr.AddHandler(
    "/hello","hello",False)
        srvr.Port=port
        srvr.Start
        StartMessageLoop
    End Sub
    4. Then use git push to make deployment.

    Here is an example: https://b4jserver.azurewebsites.net/hello
     

    Attached Files:

    Mashiane, tchart, thinktank and 11 others like this.
  2. tchart

    tchart Active Member Licensed User

    Hi xulihang, this looks awesome. Could you provide more details on how you do the git clone and jar replacement? I'm a bit stuck.
     
  3. xulihang

    xulihang Active Member Licensed User

    Get the DEPLOYMENT TRIGGER URL in Properties and you can clone it. It's like
    https://b4j-server.scm.azurewebsites.net/

    You can see or set your own credentials in development center.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice