none
[Python][Web Apps] Importing a Flask Web App RRS feed

  • Question

  • Hello,

    I am currently trying to import a flask web app into azure so that I can deploy it. Right now, my website only runs locally but I want to put it on the web with Azure. My web app communicates with a Microsoft sql server database and I believe I already have that set up properly. I am trying to follow along with this tutorial (https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-create-deploy-flask-app/#web-app-development---maclinux---command-line) but I have gotten stuck at the section where I am supposed to clone the repo. I completed the tutorial for setting up continuous deployment with Git. The files that Azure initializes a Flask Web App with are not showing up in Visual Studio after cloning the project with the URL given from the portal. If anyone could help me get this website up and running with Azure, I would greatly appreciate it!



    Sunday, May 29, 2016 10:19 PM

Answers

  • I am a little confused about your issue. Do you create the App Service with a Flask template or with an default template. 

    As you said that you already have a Flask app on local, you can create an App Service without any template, then directly deploy your local Flask app to Azure via Git. Directly start begin https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-create-deploy-flask-app/#web-app-development---maclinux---command-line.

    Generally, you can try the following steps:

    1. In your Flask app's root directory, create virtual environment as mentioned by the link above 
    2. run commands:
    git init
    git add .
    git commit -m "init"
    git remote add azure <your_site_repo_url>
    git push azure master
    Any further concern, please feel free to let me know.
    Monday, May 30, 2016 6:17 AM
    Moderator

All replies

  • I am a little confused about your issue. Do you create the App Service with a Flask template or with an default template. 

    As you said that you already have a Flask app on local, you can create an App Service without any template, then directly deploy your local Flask app to Azure via Git. Directly start begin https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-create-deploy-flask-app/#web-app-development---maclinux---command-line.

    Generally, you can try the following steps:

    1. In your Flask app's root directory, create virtual environment as mentioned by the link above 
    2. run commands:
    git init
    git add .
    git commit -m "init"
    git remote add azure <your_site_repo_url>
    git push azure master
    Any further concern, please feel free to let me know.
    Monday, May 30, 2016 6:17 AM
    Moderator
  • Hello,

    So I ended up figuring out my previous issue with the Git repo. Now I have my flask app 'imported' and it runs perfectly locally when I'm in Visual Studio and press F5 and all of that. Once I deploy it (commit and sync my changes) to azure and try to browse the URL, I get this "The page cannot be displayed because an internal server error has occurred.". Upon further inspection, I found that I was getting this error log:

    </head> 
    <body> 
    <div id="content"> 
    <div class="content-container"> 
    <h3>HTTP Error 500.0 - Internal Server Error</h3> 
    <h4>The page cannot be displayed because an internal server error has occurred.</h4> 
    </div> 
    <div class="content-container"> 
    <fieldset><h4>Most likely causes:</h4> 
    <ul> 	<li>IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.</li> 	<li>IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.</li> 	<li>IIS was not able to process configuration for the Web site or application.</li> 	<li>The authenticated user does not have permission to use this DLL.</li> 	<li>The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.</li> </ul> 
    </fieldset> 
    </div> 
    <div class="content-container"> 
    <fieldset><h4>Things you can try:</h4> 
    <ul> 	<li>Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.</li> 	<li>Check the event logs to see if any additional information was logged.</li> 	<li>Verify the permissions for the DLL.</li> 	<li>Install the .NET Extensibility feature if the request is mapped to a managed handler.</li> 	<li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul> 
    </fieldset> 
    </div> 
     
    <div class="content-container"> 
    <fieldset><h4>Detailed Error Information:</h4> 
    <div id="details-left"> 
    <table border="0" cellpadding="0" cellspacing="0"> 
    <tr class="alt"><th>Module</th><td>&nbsp;&nbsp;&nbsp;FastCgiModule</td></tr> 
    <tr><th>Notification</th><td>&nbsp;&nbsp;&nbsp;ExecuteRequestHandler</td></tr> 
    <tr class="alt"><th>Handler</th><td>&nbsp;&nbsp;&nbsp;Python FastCGI</td></tr> 
    <tr><th>Error Code</th><td>&nbsp;&nbsp;&nbsp;0x00000000</td></tr> 
     
    </table> 
    </div> 
    <div id="details-right"> 
    <table border="0" cellpadding="0" cellspacing="0"> 
    <tr class="alt"><th>Requested URL</th><td>&nbsp;&nbsp;&nbsp;http://virtualcamp:80/handler.fcgi/</td></tr> 
    <tr><th>Physical Path</th><td>&nbsp;&nbsp;&nbsp;D:\home\site\wwwroot\handler.fcgi\</td></tr> 
    <tr class="alt"><th>Logon Method</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr> 
    <tr><th>Logon User</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr> 
     
    </table> 
    <div class="clear"></div> 
    </div> 
    </fieldset> 
    </div> 
     
    <div class="content-container"> 
    <fieldset><h4>More Information:</h4> 
    This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error. 
    <p><a href="http://go.microsoft.com/fwlink/?LinkID=62293&amp;IIS70Error=500,0,0x00000000,9200">View more information &raquo;</a></p> 
    <p>Microsoft Knowledge Base Articles:</p> 
      
     
    </fieldset> 

    I've been searching these errors and I think it has something to do with my connection to my Azure SQL DB. In my web app application setting I put in the connection string copied from my SQL DB. I used the ODBC since in my python server code I use pypyodbc.connect, which works fine locally. I also used the SQL database setting and saved the changes.

    Is there something that I am doing wrong here?

    Any help is appreciated!

    -Isaiah

    Monday, May 30, 2016 7:07 PM
  • Can you have a try to directly set the Azure SQL connection string in the Flask application for checking whether is the connection issue?

    And by the way, you can leverage PTVS to remote debugging your python application on Azure. Refer to https://github.com/Microsoft/PTVS/wiki/Azure-Remote-Debugging for more.

    Tuesday, May 31, 2016 7:00 AM
    Moderator