Getting started with Django in a Linux Virtual Machine on Windows Azure


Uploaded by windowsazure on 07.06.2012

Transcript:
Hello my name is Dino Viehland and today I will be showing you
how to deploy Django application to Linux VM inside of Windows Azure
So the first thing I need to do is create a new Virtual Machine
so here I am at the Windows Azure portal site and I will click on New in the bottom
left-hand corner
I will select Virtual Machine
and from Gallery
In here will see Ubuntu Server and that's the image type I will use to deploy
Type in a machine name and the username
and password
and click on next
Give it a
DNS name
click on next
and OK
And you can see that we start provisioning our Web Site
In a little bit our Web Site will be available and we will be able to
SSH into it
So, my site is now running and the next thing I'm going to do is drill into that
and set up a new endpoint so that I can connect with it via a web server
I will add the endpoint
and we will just call it
Http
public Port 80 and private Port 80
OK, so now we are in our Terminal and we are just going to go ahead and connect to that machine
I will enter my password
and now we are logged in
So the first thing we are going to do is install some software
We are going to start off with installing Python setup tools package and this will let us
install Django next
Next, we are going to use easy-install, which we just installed
to install Django
And, last but not least we will go ahead and install Apache
Okay, now we are ready to start creating our actual Django application
So I am going to make a Django directory here
And I will then use the Django admin script
to start a project
and we'll just call that Hello World
I'll go into to Hello World directory and you can see this is what you
typically expect from a Django project We have
a Hello World subdirectory, which actually contains our app and we have manage.py
Next we need to go ahead and create a views.py, which will handle our requests
So the first thing I need to is
import HttpResponse from Django
And I will define a Hello method which takes a request
And we'll just return a new HttpResponse
The body
that says Hello world
Write that out
The next thing I am going to do is update our URLs file so that it contains a mapping to our newly
created
Hello World handler
So first I'm going to
import
my actual
handler and then I will set up the mapping
which maps request from the route
to our Hello World method
Finally
I need to update
our configuration for Apache
So I will come into Httpd.com and add a
script alias
pointing at our
Django
wsgi.py handler
And we will set up our PythonPath
so that it knows to look where we created our new application
Finally, we need to enter some configuration information about the
directory itself
And set up some permissions
and we will go ahead and write that out
Now we just need of restart Apache
Finally, we are ready to load it up into the Web browser, so start Safari
Go to our URL
and Hello World
We've just created our Web Site in the cloud running on Windows Azure
running on a Linux VM
Thanks for watching