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:
- Make sure your
requirements.txt
file lists all the necessary dependencies in plain text:aiohttp==3.8.1
gunicorn==20.1.0
- 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 yourrequirements.txt
. So, place yourrequirements.txt
in the root directory of your project. Azure App Service looks for this file to install dependencies. - 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)
gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP
-
- 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.
- 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:
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