question

PRajathK-7958 avatar image
0 Votes"
PRajathK-7958 asked ajkuma-MSFT edited

I cant load any python modules in azure web apps

/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-webapps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PRajathK-7958 avatar image
0 Votes"
PRajathK-7958 answered ajkuma-MSFT converted comment to answer

@ajkuma-MSFT

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@PRajathK-7958, Thanks for the quick follow-up and additional info.

Kindly let me know if you have added SCM_DO_BUILD_DURING_DEPLOYMENT to your application settings and have it set to true. This setting ensures that the virtual environment in the App Service is correctly installing your dependencies. See this for more info.

If the issue still persists, I'll follow-up with you privately to get some info about your subscription for deeper investigation.


0 Votes 0 ·

SCM_DO_BUILD_DURING_DEPLOYMENT =true , added in my starup command but aalso not worked.

0 Votes 0 ·
ajkuma-MSFT avatar image
0 Votes"
ajkuma-MSFT answered ajkuma-MSFT commented

@PRajathK-7958, 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.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Additionally, to provide your more clarity on how it works on App Service.

A:

To provide more clarity on this, in Azure App service, you can have different flavor/version of WebApp, as follows:

1.Code + Linux (WebApp Linux) - App Service on Linux provides pre-defined application stacks on Linux with support for languages such as .NET, PHP, Node.js and others. These are blessed images, predefined by platform. Here you just deploy your code.

  1. Docker Container + Linux (WebApp for Container) – custom image (code already part of the image, and not deployed separately) - container image become containers at runtime.

B:
To highlight further on container start-up process - When your site starts, we run your Docker image and create a Docker container. Your app runs inside of that container, and the file system contains only what is in the Docker image. If your Docker image doesn't install a particular component, it won't be there when your container starts. You can take charge of this by building your own custom image that will install this without manual intervention.

0 Votes 0 ·

C:
Based on your comment about not loading the modules. Typically, if you see an error like ModuleNotFoundError: No module named 'example', this means that Python could not find one or more of your modules when the application started. This most often occurs if you deploy your virtual environment with your code. Virtual environments are not portable, so a virtual environment must not be deployed with your application code. Instead, let Oryx create a virtual environment and install your packages on the web app by creating an app setting, SCM_DO_BUILD_DURING_DEPLOYMENT, and setting it to 1. This will force Oryx to install your packages whenever you deploy to App Service.

0 Votes 0 ·
ajkuma-MSFT avatar image
0 Votes"
ajkuma-MSFT answered ajkuma-MSFT edited

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

@PRajathK-7958, 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.







image.png (45.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.