Man8Blue
Man8Blue

Reputation: 1197

How to deploy Flask+ Python application on Windows Azure?

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?

Upvotes: 7

Views: 7148

Answers (2)

Mark Cowlishaw - MSFT
Mark Cowlishaw - MSFT

Reputation: 441

Assuming you want to create a cloud service, the easiest way to start would be using Windows Azure PowerShell and the new template feature - this allows you to create custom scaffolding for your own roles. You would place the necessary role setup for installing Python and Flask runtimes in the template folder, and then use Publish-AzureServiceProject to publish to Azure.

There is built-in support for Django web roles, so you might actually start from there and make the modifications necessary to support Flask.

The other option would be to use a Linux VM, which you could set up yourself via SSH. PowerShell or the cross-platform CLI would be a big help here, see: http://www.windowsazure.com/en-us/develop/nodejs/tutorials/linux-virtual-machine/ for a walk through on virtual machines.

Upvotes: 4

Colonel Panic
Colonel Panic

Reputation: 137752

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

enter image description here

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

  1. Working directory is different to Heroku (at the IIS site root, rather than the Flask site root)
  2. 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" />

Upvotes: 5

Related Questions