This project has moved and is read-only. For the latest updates, please go here.

Windows Azure deployment

Jun 14, 2012 at 1:05 PM


I am intrigued by the feature that creates an Azure Web Role from a python application. I have seen that it created a statup task that runs an EXE shipped with PTVS. I am curious about what that EXE does?

Does it work if my uses a different server than the Django server, for instance the gevent wsgi server ( Also, does it set up a reverse proxy (like IIS ARR) or does it serve directly?



Jun 14, 2012 at 5:52 PM

You can see the source code to AzureSetup here:


Basically what it does is make sure IIS is setup w/ FastCGI and then installs a FastCGI handler which is the Python interpreter running our script [].  It also parses an AzureSetup.cfg file and uses that to install the Python interpreter and Django (from a WebPI feed), and get some paths. 

There's not a lot that's Django specific in there but there are a few bits and pieces.  There's the fact that we set the DJANGO_SETTINGS_MODULE env var and the script defaults to Django's WSGI handler - but this can be overridden with the WSGI_HANDLER env var. 

So the support another wsgi server should be as simple as abstracting away the setting of the DJANGO_SETTINGS_MODULE variable and enable setting the WSGI_HANDLER env var - so in general adding some support to AzureSetup so you can specify specific env vars with some parameterization.  That just needs to be something written out to AzureSetup.cfg which gets generated by our Microsoft.PythonTools.Django.targets file today (  We'd welcome a contribution back which does this - also you could test it out in the Azure emulator before testing it out in Azure for real, we'll go through the same basic steps either way.

The requests then all get served via IIS via the FastCGI gateway talking to the Python interpreter running the script.

Jun 15, 2012 at 3:31 PM

Thanks for the details. My app uses gevent, which required that the server processes the HTTP requests on greenlets rather than theads. That's why gevent provides a custom http server, that runs an event loop and serves requests on greenlets. I suppose it means that won't work if I run with IIS FastCGI, because IIS provisions the threads, and doesn't know anything about greenlets. Is that correct, or is there a way to make it work somehow? (maybe modifying


Jun 15, 2012 at 4:10 PM

Yes, I think you're right that using IIS probably won't work here.  I think this is probably best positioned for using the new VM roles rather than the cloud services (the "web role" with IIS). 

In a VM you can easily run anything you want - including your custom HTTP server.  You then just need to configure the VM to have a mapping between the internal end point (port number) to an external end point - which can just be map port 80 to port 80. 

This video is a walkthrough of how to do this with a Linux VM from a Mac but it's basically the same if you want a Windows VM or if you're doing it from Windows.