How do you expose port 3000 using an Azure Web App Container?

30,821

User 4c74356b41 is correct.

In APPLICATION SETTINGS you need to set the key / value pair WEBSITES_PORT.

For some reason it's not working on this image, but I went through another example and did it all through the command line, and it worked fine.

Share:
30,821

Related videos on Youtube

Dave Voyles
Author by

Dave Voyles

Sr. Software Engineer, Microsoft DaveVoyles.com

Updated on July 09, 2022

Comments

  • Dave Voyles
    Dave Voyles almost 2 years

    I'm running a react boilerplate app within a docker container, hosted Azure Web App Containers.

    Locally, I spin the app up with:

    docker run -p 3000:3000 431e522f8a87
    

    My docker file looks like this:

    FROM node:8.9.3
    EXPOSE 3000
    RUN mkdir -p src
    WORKDIR /src
    ADD . /src
    RUN yarn install
    RUN yarn build 
    CMD ["yarn", "run", "start:prod"]
    

    APPLICATION SETTINGS

    I've tried editing the Application Settings, to no avail, with the key/value pair: WEBSITES_PORT=3000

    Apparently Azure only exposes ports 80 and 443 for inbound traffic:

    80: Default port for inbound HTTP traffic to apps running in App Service Plans in an App Service Environment. On an ILB-enabled ASE, this port is bound to the ILB address of the ASE.

    443: Default port for inbound SSL traffic to apps running in App Service Plans in an App Service Environment. On an ILB-enabled ASE, this port is bound to the ILB address of the ASE.

    How do I expose port 3000 in an Azure App Service?

    • 4c74356b41
      4c74356b41 about 6 years
      website_port is indeed the proper setting for this. docs.microsoft.com/en-us/azure/app-service/containers/…
    • Dave Voyles
      Dave Voyles about 6 years
      You may be right. The docs say you can, but some reason I'm not able to. Hmmm... "My custom container listens to a port other than port 80. How can I configure my app to route requests to that port? We have automatic port detection. You can also specify an app setting called WEBSITES_PORT and give it the value of the expected port number. Previously, the platform used the PORT app setting. We are planning to deprecate this app setting and to use WEBSITES_PORT exclusively."
  • Dave Voyles
    Dave Voyles almost 6 years
    @RıfatErdemSahin I am not sure. I never understood why it did not work in this instance unfortunately.
  • Rıfat Erdem Sahin
    Rıfat Erdem Sahin almost 6 years
    also created another thread related to this one.I am unable to run the containers in Azure. devops.stackexchange.com/questions/4543/…
  • Rıfat Erdem Sahin
    Rıfat Erdem Sahin almost 6 years
    WEBSITES_PORT worked in my case. The external port is still 80.
  • Phil
    Phil over 5 years
    after setting websites_port how do you trigger it to restart, just restart web app?
  • TorstenS
    TorstenS about 5 years
    Where would I find those APPLICATION SETTINGS?
  • Dave Voyles
    Dave Voyles about 5 years
    @TorstenS in the Azure Portal, you can find it here: docs.microsoft.com/en-us/azure/app-service/web-sites-configu‌​re