Pandas failing to install when deploying Dash app to Azure - python

I'm getting the following error message when trying to deploy my Dash app to Azure:
Error
It then cleans up and says that "Command pyton setup.py egg_info failed with error code 1 in D:\home\site\wwwroot\env\build\Pandas"
What am I doing wrong here? Is there an issue with Pandas?

Funnily enough I ran into the exact same issue for a web app that I am working on at the moment. After 5 days of trying endless solutions I have eventually managed to get my app to deploy to Azure. My app is a Flask web app but the process is pretty much the same (if you are using Django or Dash in your case) or anything else. I am providing my answer based on the most useful links that solved my issue (I checked far too many, but these did the trick!).
This seems to be a known issue with Azure and is to do with Python version and package compatability. The first thing to check here will be the version of python you are using - if you have created your virtual environment in a version of python which is > 3.4 then you will need to install the Azure Python extension. This can be found on the left hand pane of your App Service resource under the category 'Development Tools' -> 'Extensions'. Currently the latest Python extension you can install is version 3.6.4. I had to install this as I was using python 3.6.5 for my web app:
I used the following answer by Konrad Lyda to help me solve my issue : Using python 3.6 on azure app services - not working despite it is installed as extension. You will have to manually install your packages using the kudu console and by adding a .skipPythonDeployment file. This is all explained in the link. I managed to replicate the same WSGI_HANDLER Error as highlighted and some further research led me to this link: https://github.com/Cojacfar/FlaskWeb . I know this link is Flask specific but the project structure should really help. You will need to add a web.config file to your project (just take the code from the web.config file in the git project) and replace the 'WSGI_HANDLER' value to the name of your app file. My app was defined in my views.py file so the value I used was 'views.app'.
The line that did it for me was:
wsgi_app = app.wsgi_app
which goes under your app declaration. For example, as I was using Flask and Flask boostrap I have the following in my app file:
app = Flask(__name__)
bootstrap = Bootstrap(app)
wsgi_app = app.wsgi_app
Once I got all my code in place I removed any unnecessary files that I did not need and deployed to Azure and it started working!
Let me know you get on. Hope this helps.

Related

deploy first django test app to anywhere (azure or heroku)

tldr; - When I have deployed a flask app in the past, it uses a requirements.txt file in the main root of the project folder so that azure or heroku can understand what modules need to be installed. However, this is the first time I am messing with django. I am trying to test deploy to azure or heroku but I azure can't detect the stack of the app because there is no requirements.txt file in the main root of the folder.
From messing with django a little bit, it seems alot more complicated than flask. What can I do to test deploy the most basic app to azure app services or heroku or aws or any place in general?
I tried deploying the django app like I normally do with flask but received an error:
Could not auto-detect the runtime stack of your app.
HINT: Are you in the right folder?
For more information, see 'https://go.microsoft.com/fwlink/?linkid=2109470'
Here is a picture of what I am seeing on my side:
I would assume I am not in the right folder but I am not sure if that is the problem completely.
Here is app I am testing myself. Its a microsoft authenication test app where you can test your xbox live account, microsoft school account, or microsoft work account against the webpage: https://github.com/Azure-Samples/ms-identity-python-django-tutorial
**Of course I added the app registration information from azure. Infact, the same app registration information works on my flask app so any azure app registrations issues is probably not the issue. **
The repo you link contains multiple projects. It sounds like you need to clone this, then move one of the project sub-directories (which should have its own requirements.txt already) into a fresh working tree, initialize a new repo there, and then push that to the cloud provider.

python flask code - on windows through HTTP request

I have come with python flask code which uses python libraries pywin32 and pYAD. I need to run these in production enviornment.
I tried to enable it over IIS through wfastcgi but its not working as expected.
Is there a way I can leverage the script to use in production set up, I have tried using Always Up converting script as a service but its not allowed in my organization similar with NSSM.
Is there any other way to explore this. Kindly help
Thanks
You can try waitress. You'll find the documentation Here.
Install Waitress
pip install waitress
setup.py file
from waitress import serve
import main
serve(main.app, host='0.0.0.0', port=8080) #'main.app' being your entry point
run setup.py and access your app through http://host_ip_address:8080

Azure publishing error Flask Web App

I have FLask Web app that i published as azure web app. Im getting this error.
I created new resource, downloaded publishing profile and published it from visual studio using the downloaded file. Can someone else tell me what is Microsoft.cis.monitoring.query for? I tried to search around and only things that came up was related to cloud services/worker roles, which i dont believe im using in my project.
my project debug/release was set to "Any CPU".
Things ive tried based on similar questions on here:
changed debug/release to x32
changed debug/release to x64
changed debug/release to x86
i tried all three setttings. (build->configuration->platform) & (solution properties->platform target)
I initialized the webb app using +->web+mobile->web app
Thank you peterPan! Seems like my project somehow was including 'web role' file under project->bin i went ahead and delete and it ran fine. Azure was looking at my projet as a cloud service instead of a web app.

Importing mysql.connector into Azure Flask Project

I'm trying to deploy a Flask web app with mysql connectivity. It's my first time using Azure, and coming off Linux it all seems pretty confusing.
My understanding is that one includes within the requirements.txt to include the packages required. When I build the default Flask app from Azure the file looks like this:
Flask<1
At this stage the site loads fine.
If I then include an additional line
https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.14.tar.gz
As per this answer https://stackoverflow.com/a/34489738/2697874
Then in my views.py file (which seems to be broadly synonymous to my old app.py file) I include...import mysql.connector
I then restart and reload my site...which then returns the error The page cannot be displayed because an internal server error has occurred.
Error logging spits out a load of html (seems pretty weird way to deliver error logs - so I must be missing something here). When I save to html and load it up I get this...
How can I include the mysql.connector library within my Flask web app?
Per my experience, the resoure https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.14.tar.gz is for Linux, not for Azure WebApps based on Windows, and the link seems to be not available now.
I used the command pip search mysql-connector to list the related package. Then, I tried to use mysql-connector instead of mysql-connector-python via pip install, and tried to import mysql.connector in local Python interpreter that works fine.
So please use mysql-connector==2.1.4 instead of mysql-connector-python== in the requirements.txt file of your project using IDE, then re-deploy the project on Azure and try again. The package will be installed automatically as the offical doc said as below.
Package Management
Packages listed in requirements.txt will be installed automatically in the virtual environment using pip. This happens on every deployment, but pip will skip installation if a package is already installed.
Any update, please feel free to let me know.

Flask app doesn't builds on MS Azure cloud

I want to deploy my flask web application on Azure cloud. In Deployment options, I have selected GitHub as source destination for my flask code. after doing the configuration test successfully, the init.py file now starts building;
Now when I go to my application link, it shows me this;
Now at this point, I went back to my deployment options, it says Building failed;
the log generated for this building failed can be seen in the first picture. All the tests has passed except the last one "Performance test". Have anyone encountered the same issue before ? what can be the reason for that ?
I am running the application on localhost # port 8000.
from flask import Flask
app = Flask(__name__)
#app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
Do I need to run it on another IP ?
You cannot listen on port 8000 in Web Apps. Only port 80 or 443. You'll need to read the port number from the environment, to know what to listen on.
If you created the Azure Webapp using the Flask tool, the default app is called FlaskWebProject1. If your app has a different name, you need to modify web.config in your wwwroot folder to reflect the correct app name.
Then redeploy using the Azure portal or change it in your GIT and push again.
Based on your 500 error, I think some python packages are not installed correctly.
To check your code is working correctly in naive manner, do as follows.
If you are developing on Windows machine, copy all of your site-packages files in development machine to WebApp /site/wwwroot/env/Lib/site-packages folder.
Hit Restart in Azure Portal and F5 in browser.
If it works, your deployment process might have a problem. Mainly it is caused by library installation.
First, check you have requirements.txt at the root folder. This documentation describes some considerations to load Flask on Azure WebApp. Of course, it would be really helpful to read the documentation from the first line carefully.
Second, login WebApp via FTP and check the package is installed correctly. You can see /pip folder has pip.log file, and /site/wwwroot/env/Lib/site-packages folder has its libraries.
For some libraries which you might require more than simple hello world app, you may have to push x86 .whl files along with python codes as they are not installed correctly in x86 environment.
Additionally, in order to show internal error to outside, consider to apply this option during development (not for production).

Categories

Resources