Share via


Using Virtual environment to Build your application for Azure

Python stack on Windows Azure is bare bones and may not include all the libraries that your application may require. The best way to build your application for Azure is setting up a virtual environment for your application that you can deploy to Windows Azure website . Here is what you need to do to setup your own development environment for your application :

Install virtualenv

If you don’t have virutalenv installed , you can install it using PIP or Easy install tools . Make sure you have python setup tools installed for Python 2.7.x . Run the following command to install virtualenv

c:\python27>Scripts\easy_install virtualenv

or

c:\python27>Scripts\ pip ``installvirtualenv

Activate your Virtual Environment

After installing virtualenv, you can create a new development environment for your application . Go to the application folder and run the following command

virtualenv `` --no-site-packages ``myapp

Here, virtualenv creates a folder, myapp/ , and sets up a clean copy of Python inside for you to use. It also installs the python setup tools so you can start building your own custom environment that includes all the modules you need for your application .

Activate your newly created environment so you can begin working within it.

C:\myprojects\my``app>Scripts\``activate

Now, you can install any modules or libraries your application needs . For example if my application requires Flask , then run the command

pip ``installFlask

This will install Flask in the newly created environment under Lib/site-packages . Similarly you can install any module or library your application requires.

Known Issue  and Workaround

wfastcgi should does not enable .pth files in the user's directory

Azure using wfastcgi.py as the FASTCGI handler for managing requests to your application . If the application modules are installed as .EGG files , then wfastcgi.py wont be able to find the module you are using with your application . You can track the issue here

Workaround : You can install application using PIP or Easy install tools and then rename the EGG files as ZIP files . Now open the ZIP file and extract all the contents into site-packages folder .