App service won't run my Docker via python

Jesper Petersen 45 Reputation points
2023-08-14T19:25:47.1433333+00:00

This is how I used VS code to upload my images to Azure. and upload two version of it. But when I have to have the App Service make use of Docker that I have uploaded, it gets the name but it just doesn't come up and run at all. Is it because I'm missing something for it to work?
1

Dockerfile:

FROM python:3.8

COPY service/clubs.py /app/service/clubs.py
COPY service/commands.py /app/service/commands.py
COPY service/logger.py /app/service/logger.py
COPY service/task.py /app/service/task.py
COPY service/layout.py /app/service/layout.py
COPY service/helpers.py /app/service/helpers.py

RUN pip install discord
CMD ["python", "index.py"]

Docker-compose:

version: '3'
services:
  web:
    container_name: "fmbotdiscord"
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "5000:5000"
    volumes:
      - ./index.py:/app/index.py
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,667 questions
0 comments No comments
{count} votes

Accepted answer
  1. brtrach-MSFT 17,651 Reputation points Microsoft Employee
    2023-08-18T01:21:17.9433333+00:00

    @Jesper Petersen Regarding the issue you are facing, the suggestion provided by @Ben Gimblett mentioned is correct (Thank you Ben). You need to specify the port that your application is listening on in the Azure App Service configuration. By default, Azure App Service listens on port 80 for HTTP traffic and port 443 for HTTPS traffic. If your application is listening on a different port, you need to specify it in the configuration.

    To specify the port, you can set the WEBSITES_PORT environment variable in the Azure App Service configuration. You can do this using the Azure Portal or the Azure CLI. Here is an example of how to set the WEBSITES_PORT environment variable using the Azure CLI:

    az webapp config appsettings set --resource-group <resource-group-name> --name <app-name> --settings WEBSITES_PORT=5000
    

    Replace <resource-group-name> with the name of your resource group and <app-name> with the name of your app service.

    After setting the WEBSITES_PORT environment variable, you should be able to access your application on Azure App Service using the URL http://<app-name>.azurewebsites.net:<port>, where <app-name> is the name of your app service and <port> is the port that your application is listening on.

    Let me know if you have any other questions.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Ben Gimblett 4,555 Reputation points Microsoft Employee
    2023-08-15T13:29:33.7+00:00

    Hi - thanks for the question
    One thing to check here (as you're not using standard http port) is that you tell app service which port to forward to
    Please refer to https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/faqs-app-service-linux#how-do-i-specify-port-in-my-linux-container-

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.