How to deploy Flask+ Python application on Windows Azure?

azure, flask, python, web-services

Solution

As of July 2013 there's a Flask template on Azure.

Start with that. Clone it to your computer. There's some IIS stuff at the root, and a hello world Flask in the folder `FlaskApplication`. You can test the Flask app on your computer `python __init__.py`. I don't know how to test the IIS site locally.

I don't know how dependencies work either. There's a Pip `requirements.txt` in the template, and also the source trees of Flask and a couple of other libraries.

I copied an app of mine from Heroku to Azure. Got it working eventually. The biggest difficulty was finding and reading logs (you need to turn on all the logging in the IIS manager, then browse to an FTP site, then the logs are deep in some weird named xml file), which made the two minor problems take longer than they should to solve

- Working directory is different to Heroku (at the IIS site root, rather than the Flask site root)

- The template has a dodgy `web.config` that silently deletes query strings from get requests

This was the problem

 <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="false" />

Problem

I recently developed an App in Flask + Python with PostgreSQL as database. How can I upload my app on Windwos Azure? Does Windows Azure support Flask? Is it worth installing Flask app on Windows Azure virtual machine? A lot of tutorials instruct to use Visual Studio and IPython with Django but that's not my choice. Is there any guide or tutorial to get started?

Original source