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 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:

    thinktank, miker2069, Don Oso and 9 others like this.
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