I cant load any python modules in azure web apps

P, Rajath K 96 Reputation points
2021-09-24T14:41:45.367+00:00

/home/LogFiles/2021_09_23_pl0sdlwk00008N_docker.log (https://ddsdemofinal.scm.azurewebsites.net/api/vfs/LogFiles/2021_09_23_pl0sdlwk00008N_docker.log)
2021-09-23T23:51:38.439Z INFO - Stopping site ddsdemofinal because it failed during startup.
2021-09-23T23:56:42.434Z INFO - Starting container for site
2021-09-23T23:56:42.435Z INFO - docker run -d -p 7090:8000 --name ddsdemofinal_0_27fc8fd5 -e WEBSITE_SITE_NAME=ddsdemofinal -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=ddsdemofinal.azurewebsites.net -e WEBSITE_INSTANCE_ID=4e34fd1dcf287fe6e10b93d54f0687cf933ff0e6150f35901216ccdf393ab071 appsvc/python:3.7_20210709.2 source /home/site/wwwroot/peifront/bin/activate

2021-09-23T23:56:42.436Z INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2021-09-23T23:56:43.618Z INFO - Initiating warmup request to container ddsdemofinal_0_27fc8fd5 for site ddsdemofinal
2021-09-23T23:56:45.939Z ERROR - Container ddsdemofinal_0_27fc8fd5 for site ddsdemofinal has exited, failing site start
2021-09-23T23:56:45.941Z ERROR - Container ddsdemofinal_0_27fc8fd5 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2021-09-23T23:56:45.944Z INFO - Stopping site ddsdemofinal because it failed during startup.

/home/LogFiles/2021_09_24_pl0sdlwk00008N_default_docker.log (https://ddsdemofinal.scm.azurewebsites.net/api/vfs/LogFiles/2021_09_24_pl0sdlwk00008N_default_docker.log)
2021-09-24T14:36:09.038426918Z File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
2021-09-24T14:36:09.038430918Z File "<frozen importlib._bootstrap_external>", line 728, in exec_module
2021-09-24T14:36:09.038435018Z File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2021-09-24T14:36:09.038439018Z File "/home/site/wwwroot/app.py", line 5, in <module>
2021-09-24T14:36:09.038443118Z from azure.data.tables import TableServiceClient
2021-09-24T14:36:09.038446719Z ModuleNotFoundError: No module named 'azure'
2021-09-24T14:36:09.043217235Z [2021-09-24 14:36:09 +0000] [38] [INFO] Worker exiting (pid: 38)
2021-09-24T14:36:09.098016220Z [2021-09-24 14:36:09 +0000] [35] [INFO] Shutting down: Master
2021-09-24T14:36:09.098035921Z [2021-09-24 14:36:09 +0000] [35] [INFO] Reason: Worker failed to boot.

/home/LogFiles/2021_09_24_pl0sdlwk00008N_docker.log (https://ddsdemofinal.scm.azurewebsites.net/api/vfs/LogFiles/2021_09_24_pl0sdlwk00008N_docker.log)
2021-09-24T14:27:59.184Z INFO - Stopping site ddsdemofinal because it failed during startup.
2021-09-24T14:36:04.871Z INFO - Starting container for site
2021-09-24T14:36:04.873Z INFO - docker run -d -p 3764:8000 --name ddsdemofinal_0_677f8e04 -e WEBSITE_SITE_NAME=ddsdemofinal -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=ddsdemofinal.azurewebsites.net -e WEBSITE_INSTANCE_ID=4e34fd1dcf287fe6e10b93d54f0687cf933ff0e6150f35901216ccdf393ab071 appsvc/python:3.7_20210709.2

2021-09-24T14:36:04.873Z INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2021-09-24T14:36:06.859Z INFO - Initiating warmup request to container ddsdemofinal_0_677f8e04 for site ddsdemofinal
2021-09-24T14:36:10.122Z ERROR - Container ddsdemofinal_0_677f8e04 for site ddsdemofinal has exited, failing site start
2021-09-24T14:36:10.124Z ERROR - Container ddsdemofinal_0_677f8e04 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2021-09-24T14:36:10.133Z INFO - Stopping site ddsdemofinal because it failed during startup.

/home/LogFiles/webssh/.log (https://ddsdemofinal.scm.azurewebsites.net/api/vfs/LogFiles/webssh/.log)

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,374 questions
0 comments No comments
{count} votes

Accepted answer
  1. P, Rajath K 96 Reputation points
    2021-09-27T10:12:55.49+00:00

    @ajkuma

    2021-09-24T14:36:09.038443118Z from azure.data.tables import TableServiceClient
    2021-09-24T14:36:09.038446719Z ModuleNotFoundError: No module named 'azure'

    2021-09-24T14:36:09.043217235Z [2021-09-24 14:36:09 +0000] [38] [INFO]

    above is the issue , i am facing.
    i checked under wwwroot folder requirements,txt updated, also my venv also updated.
    but why from azure.data.tables import TableServiceClient this line not working idon't know,
    if i comment it , application is able to deploy.
    building using command : az webapp up --sku B1 --name ddsdemo

    azure-core==1.18.0
    azure-data-tables==12.1.0
    certifi==2021.5.30
    charset-normalizer==2.0.6
    click==8.0.1
    Flask==2.0.1
    idna==3.2
    isodate==0.6.0
    itsdangerous==2.0.1
    Jinja2==3.0.1
    MarkupSafe==2.0.1
    msrest==0.6.21
    numpy==1.21.2
    oauthlib==3.1.1
    python-dateutil==2.8.2
    pytz==2021.1
    requests==2.26.0
    requests-oauthlib==1.3.0
    six==1.16.0
    urllib3==1.26.6
    Werkzeug==2.0.1


2 additional answers

Sort by: Most helpful
  1. ajkuma 24,736 Reputation points Microsoft Employee
    2021-09-27T11:18:47.653+00:00

    <<To benefit the community, the issue was resolved by following these steps (copying from our 'comments' discussion: >>

    @P, Rajath K , Just to confirm, since you have mentioned that you have added this as a startup command, kindly add it as application setting as below:

    1. Go to the Azure Portal (https://portal.azure.com )
    2. Select your Python app that is running on App Service on Linux
    3. Go to Configuration
    4. Add a new application setting.
    5. Enter SCM_DO_BUILD_DURING_DEPLOYMENT=true and press OK
    6. Press the Save button

    135571-image.png

    I'm also reaching out you privately.

    0 comments No comments

  2. ajkuma 24,736 Reputation points Microsoft Employee
    2021-09-27T09:44:49.45+00:00

    @P, Rajath K , Firstly, apologies for the late response from over the weekend.

    1. Based on the error message it appears to be an issue with the port on which it’s listening on.

    By default, App Service assumes your custom container is listening on port 80. If your container listens to a different port, as in your case, you need set that
    WEBSITES_PORT (for customer containers) app setting only in your App Service app.

    To manually configure a custom port, use the EXPOSE instruction in the Dockerfile and the app setting, WEBSITES_PORT, with a port value to bind on the container.

    Whereas, for default/blessed image, the PORT variable is not necessary to automatic port detection. If no port is detected, it defaults to 80.
    The WEBSITES_PORT app setting does not have any effect within the container, and you can’t access it as an environment variable within the container.

    Only port 80 and 8080 is accessible (exposed ports) -App Service Linux FAQ

    2.By default, if your container does not respond after 230 seconds, it will time out. (This time out can be increased by with the WEBSITES_CONTAINER_START_TIME_LIMIT app setting.)

    If your container takes a long time, you could add an app setting called WEBSITES_CONTAINER_START_TIME_LIMIT and set it to the number of seconds you would like for us to wait for your container to start (up to a maximum of 1800).

    To do this, from the Azure Portal> Navigate to your WebApp > Under Settings blade > Go to “Configuration” > Add the above app setting with ‘Name’ with 1800 as ‘Value’ .

    3. Python apps must be deployed with all the required pip modules
    Kindly see this sample.

    4. You can add start-up command for customization. Please review the bindings and check the startup command
    As mentioned in this doc -customize-startup-command

    5. The App Service container that runs Python apps has Django and Flask installed by default, along with the gunicorn web server.

    To use a framework other than Django or Flask (such as Falcon, FastAPI, etc.), or to use a different web server, do the following:

    Startup commands for other frameworks and web servers

    Also, note we cannot access your Source Control Manager (SCM)/Kudu site, it’s accessible to website owners (you and your webapp contributor).
    Note: Please do not share any PII data on the public forum.

    Kindly let us know how it goes, I'll follow-up with you further on this.