I’m getting an error when deploying EchoBot to the Azure App Service via VS Code. Module not found.

Leo Pabon 20 Reputation points
2024-06-20T01:46:15.7+00:00

I am trying to deploy a Python code based on Echo Bot from Bot Framework on Azure App Service.

It looks like it isn't installing the dependency 'aiohttp' I put on requirements.txt. I already added SCM_DO_BUILD_DURING_DEPLOYMENT=true to App Settings. I believe that I need to create some deployment script, but I don't know how to do it.

I pasted below the startup log with some errors that may help to diagnose my problem:

2024-06-19T17:36:11.659660467Z    _____                               
2024-06-19T17:36:11.660293903Z   /  _  \ __________ _________   ____  
2024-06-19T17:36:11.660302104Z  /  /_\  \\___   /  |  \_  __ \_/ __ \ 
2024-06-19T17:36:11.660307404Z /    |    \/    /|  |  /|  | \/\  ___/ 
2024-06-19T17:36:11.660312304Z \____|__  /_____ \____/ |__|    \___  >
2024-06-19T17:36:11.660317505Z         \/      \/                  \/ 
2024-06-19T17:36:11.660321805Z A P P   S E R V I C E   O N   L I N U X
2024-06-19T17:36:11.660325905Z 
2024-06-19T17:36:11.660330205Z Documentation: http://aka.ms/webapp-linux
2024-06-19T17:36:11.660334506Z Python 3.9.18
2024-06-19T17:36:11.660338706Z Note: Any data outside '/home' is not persisted
2024-06-19T17:36:13.810554703Z Starting OpenBSD Secure Shell server: sshd.
2024-06-19T17:36:14.333770281Z Site's appCommandLine: gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP
2024-06-19T17:36:14.354694284Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand 'gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP'
2024-06-19T17:36:14.813647468Z Could not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2024-06-19T17:36:14.836126760Z Could not find operation ID in manifest. Generating an operation id...
2024-06-19T17:36:14.836167062Z Build Operation ID: 3ea9efd5-76gt-98jb-b4ccb93fd
2024-06-19T17:36:15.757313818Z Oryx Version: 0.2.20240501.1, Commit: f83f88d3c, ReleaseTagName: 20240501.1
2024-06-19T17:36:15.803859894Z Writing output script to '/opt/startup/startup.sh'
2024-06-19T17:36:15.876379163Z WARNING: Could not find virtual environment directory /home/site/wwwroot/antenv.
2024-06-19T17:36:15.878094662Z WARNING: Could not find package directory /home/site/wwwroot/__oryx_packages__.
2024-06-19T17:36:21.199999677Z 
2024-06-19T17:36:21.216749143Z Error: class uri 'aiohttp.worker.GunicornWebWorker' invalid or not found: 
2024-06-19T17:36:21.216757743Z 
2024-06-19T17:36:21.216762344Z [Traceback (most recent call last):
2024-06-19T17:36:21.216766944Z   File "/opt/python/3.9.18/lib/python3.9/site-packages/gunicorn/util.py", line 111, in load_class
2024-06-19T17:36:21.216771844Z     mod = importlib.import_module('.'.join(components))
2024-06-19T17:36:21.216776544Z   File "/opt/python/3.9.18/lib/python3.9/importlib/__init__.py", line 127, in import_module
2024-06-19T17:36:21.216781145Z     return _bootstrap._gcd_import(name[level:], package, level)
2024-06-19T17:36:21.216785545Z   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2024-06-19T17:36:21.216790645Z   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2024-06-19T17:36:21.216806746Z   File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
2024-06-19T17:36:21.216811746Z   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2024-06-19T17:36:21.216816347Z   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2024-06-19T17:36:21.216820647Z   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2024-06-19T17:36:21.216825147Z   File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
2024-06-19T17:36:21.216829547Z ModuleNotFoundError: No module named 'aiohttp'
2024-06-19T17:36:21.216834048Z ]
2024-06-19T17:36:21.216838248Z 

rs-app-service_0_9031ba9f_middleware for site rs-app-service initialized successfully and is ready to serve requests.
2024-06-19T17:36:36.343Z ERROR - Container rs-app-service_0_9031ba9f didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2024-06-19T17:36:36.481Z INFO  - Stopping site rs-app-service because it failed during startup.

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
774 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,219 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sina Salam 5,716 Reputation points
    2024-06-20T22:32:12.2533333+00:00

    Hello Leo Pabon,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    Problem

    I understand that you are having an error when deploying EchoBot to the Azure App Service via VS Code "Module not found".

    Solution

    Based on the information you provided, it signifies that error you're experiencing suggests that the aiohttp module is not being installed during your deployment to Azure App Service. To simplify the process to ensure that your dependencies, including aiohttp, are installed during deployment to Azure App Service, you can use the built-in functionality of Azure to handle your application's dependencies without the need for a custom script.

    I put together the few steps to accomplish this in the followings:

    1. Make sure your requirements.txt file lists all the necessary dependencies in plain text: aiohttp==3.8.1 gunicorn==20.1.0
    2. Azure App Service can automatically install the dependencies listed in your requirements.txt file if you ensure the setup is correct. This often involves making sure Azure's deployment process is correctly configured to find and use your requirements.txt. So, place your requirements.txt in the root directory of your project. Azure App Service looks for this file to install dependencies.
    3. Go to your App Service in the Azure portal, navigate to "Configuration" > "Application settings", and ensure the following settings are present:
      • SCM_DO_BUILD_DURING_DEPLOYMENT=true
      • WEBSITE_RUN_FROM_PACKAGE=1 (optional but can help streamline deployments)
      After the above, make sure the startup command in your App Service configuration points to your application’s entry point. For example: gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP
    4. Use the Azure App Service updated extension in Visual Studio Code to deploy your application. Ensure you login into your Azure account in VS Code as you have done before.
    5. After deployment, monitor the logs in the Azure portal to ensure your app is starting correctly and that all dependencies are installed. You can view the logs by navigating to your App Service and selecting "Log Stream".

    References

    For more information and detail configurations, kindly use the following links:

    How to use requirements.txt

    Deploy Python apps to Azure App Service using Visual Studio Code

    Application settings reference for Azure App Service

    Accept Answer

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.

    Best Regards,

    Sina Salam

    0 comments No comments

  2. YutongTie-MSFT 47,761 Reputation points
    2024-06-20T22:54:45.9033333+00:00

    Hello Leo Pabon

    Thanks for reaching out to us, could you please share the code sample you are working on so that we can reproduce your issue?

    I have seen the same issue when the package has been added successfully or not added in the right environment. Could you please try this as well?

    pip3 install aiohttp
    

    Regards,

    Yutong

    -Please kindly accept the answer if you feel helpful to support the community, feel free to let us know if you have any other questions. Thanks!

    0 comments No comments