Saturday, June 9, 2012

Reintroducing Windows Azure, Part 2: Windows Azure Web Sites

In this series we’re taking a fresh look at Windows Azure, which was re-launched on June 7 with a highly-publicized Meet Windows Azure event. Here in Part 2, we’ll explore the new Windows Azure Web Sites (WAWS) feature.
What are Windows Azure Web Sites for?
As we mentioned in Part 1, the new Windows Azure can be used at 3 levels. Two of these are well-known cloud categories: Virtual Machines provides Infrastructure-as-a-Service (IaaS), and Cloud Services provides Platform-as-a-Service (PaaS). PaaS, the traditional offering in Windows Azure, has many attractive qualities including automated management and a powerful collection of services for compute, storage, relational data, caching, communication, identity, networking, and more.
You can run web sites at either the PaaS and IaaS level, so why a third mode for using the cloud just for web sites? Well, PaaS and IaaS both force some compromises on you. PaaS often requires you to make application changes to accommodate the platform—which means portability suffers. IaaS, in contrast, doesn’t require you to change the way you do things—but it comes with the burden of self-management. Wouldn’t it be nice to combine the best of IaaS (“I don’t have to change the way I do things”) with the best of PaaS (“managed for me”)? That’s what Windows Azure Web Sites provides—but at the expense of architectural versatility: it’s only for 2-tier web sites that can run on IIS such as ASP.NET, PHP, or node.js. Since the vast majority of applications hosted in the cloud are web-based it’s appropriate to have this facility.

Three Modes for using Windows Azure
Since you can host web sites at all three levels of Windows Azure, which should you use and when?
·         WAWS is best for simple 2-tier web sites, especially if you’re using a popular web framework like WordPress, Drupal, Umbraco, Orchard, etc.; or if there is a My SQL requirement.
·         Cloud Services are best for applications that are more complex than 2-tier sites where you want automated management; and when you want to take advantage of the many powerful services in the platform.
·         Virtual Machines are best for solutions that are complex, hybrid, or require a server product; for single-server solutions; or when you prefer to manage everything yourself.

Speed: The Velocity You’ve Been Waiting For
Windows Azure Web Sites is the fastest way to use Windows Azure. There are a couple of reasons for that. First off, provisioning of a new web site takes under a minute. That’s right, under a minute. If you’ve used Windows Azure at other levels you know that a deployment takes around 10-15 minutes, so how is this lightning-fast provisioning realized? Well, Windows Azure Web Sites share a pool of shared VMs already fired up and ready to go.
There’s another sense in which Windows Azure Web Sites are fast, and that relates to your ability to work the way you always have. There’s support for a gallery of common web frameworks such as Joomla and WordPress. And, you can deploy the way you’re used to, such as by FTP or Web Deploy. You don’t have to deal with special cloud artifacts, you don’t have to learn something new, and you don’t have to change your processes or preferred tools. That protects your ability to work productively.
WAWS Eliminates Barriers to Productivity

Creating a Web Site #1: Quick Create
Creating a new web site is a fast and simple operation:
1. In the new Window Azure management portal, navigate to the Web Sites area.
2. Click the CREATE A WEB SITE link, or click the + New button at bottom left.
3. Select the method of web site creation you want. You can quickly create a web site with or without a database; or you can select from a gallery of open source frameworks. Depending on your choice, the dialog will ask you for one or more forms of information. Here, we’ll do a Quick Create which creates an empty web site with no database.
Quick Create of a Web Site
Once you click CREATE WEB SITE to complete the dialog, you’re on your way to a provisioned web site in no time at all. You’ll first see a Creating message. Shortly thereafter, once the site is ready to go, the status will show as Running and there will be a notification that the web site creation has succeeded.
Fast Provisioning of a Web Site
If we hit the production URL for the site (shown in the portal, based on the name you specified), we’ll get a placeholder page:

Default Page for a Newly Created Web Site
From here you could proceed to deploy a site up to the cloud such as an ASP.NET web site, a PHP web site, or a node.js web site. We’ll talk about deployment later in this post, but first let’s examine two other ways to create web sites.

Creating a Web Site #2: Quick Create with Database
You can also create a web site along with a database. When we select that option, the dialog will ask you whether to use an existing database or to create a new one. You can choose between a Windows Azure SQL database or a My SQL database.
Create Web Site with Database
The My SQL database-as-a-service is provided by Microsoft’s partner ClearDB, so if you choose this option you’ll need to agree to ClearDB’s terms of service.
Selecting My SQL Database Region and Agreeing to Terms of Service
Once again you’ll see the site (and database) provisioned very quickly, and the status will show as Running when the site is ready for use.
 
If you click the site to go its detail page in the portal, you’ll see near the bottom that the site has a linked resource: the MySQL database that was created.
At this point you can deploy your web site and data to the cloud when ready.

Creating a Web Site #3: Using the Gallery
Yet a third way to create a site is to select from a gallery. When you select this method, you’re given the choice of a web framework to install on the web site. We’ll choose WordPress here in our example.

 Again, the site will be quickly provisioned and can be used once its status shows as Running.
In our case, since we selected WordPress, we can do everything directly in the cloud at this point using WordPress itself. Clicking on the URL at right takes us to the admin set up page:
Newly-created WordPress site in the cloud – set up
From here, it’s just a matter of creating content and configuring the site the way you want. Here’s what the site looks like after initial admin set up:
 Deployment
As web developers use a variety of languages and frameworks, there’s no one way to do web site deployment. Windows Azure Web Sites therefore supports a number of popular deployment methods. These include Visual Studio Web Deploy, GitHub, FTP, Team Foundation Services (TFS), and Microsoft WebMatrix.
Let’s show one of those methods, deploying by FTP using Visual Studio. Assume we’ve done a quick create of an empty web site in the cloud (see Creating a Web Site #1: Quick Create above), and now we want to create and deploy an ASP.NET MVC4 site. For our purposes, we’ll just create a standard MVC4 project from a template.
If we look at the detail page for our web site in the portal, there are links at right to set deployment credentials and to download a publishing profile. Some forms of deployment will use your administrator credentials, but for FTP we need to specify custom credentials. First, we select Reset deployment credentials and set up a username and password.

Next, we click the link to download a publishing profile. We save the .publishsettings file to disk on our local machine, in the root folder of our web project.
Now, we can perform a Publish action on our web project in Visual Studio, selecting the FTP option in the publishing dialog.


Now we sit back for the publishing operation to finish.

Soon the publishing is complete and we can try hitting our web site cloud URL again. The deployed site now looks like this:

You may be wondering how this works when you have multiple web servers – do you need to separately publish to each one? No, you don’t: Windows Azure takes care of that for you. For all effective purposes, you can pretend there’s just one web server out there to publish to even if you have 2, 20 or 200 servers in actuality.

Dashboard
Each Windows Azure Web Site has a detail page that includes a dashboard. The dashboard shows you usage metrics for the site and details about your site such as its access URL and data center locale. From here you can take site actions, such as browsing to the site, stopping/starting it, or deleting it altogether.


Scaling
From the dash you can click Scale to review or change scale settings. You can scale by changing the number of instances, using slider controls and then saving changes. There’s also the option to run in shared or reserved mode. By default, you site is running in shared mode, which means your web site is running as part of a large pool, co-habiting VMs with other web sites (with isolation protections). You can elect to move to reserved mode, where the hosting VMs are dedicated to your site only (which costs more).

Windows Azure Web Sites is a service currently in preview that you have to sign up for in order to use. Your first 10 web sites are free (in shared mode).  In reserved mode you can run Small, Medium, or Large size VMs. See
azure.com for rates and a pricing calculator.

Summary
Windows Azure Web Sites adds a compelling and low-cost cloud computing alternative to traditional IaaS and PaaS for 2-tier web sites. It provides the management benefits of PaaS without sacrificing the portability normally associated with IaaS. It’s extremely fast and productive to use. It plays well with popular web frameworks and deployment methods. It’s the way the cloud should be: easy and frictionless.

5 comments:

Anonymous said...

David,

Great introduction!!! Can you also write some of the "gotchas" one need to remember when working with Windows Azure Web Sites.

Nico de Jong said...

David,

I have not yet seen anybody mention custom URL's in the Azure Websites preview. Would one need to move to VM to have this?

@J0eSmith said...

WAWS are not limited to 2-tier. They can work with Web Roles. The only difference between WAWS and WA Web Roles is that you control the VM in a Web Role, you can run startup scripts, RDC into the machine, change application.config, registry, etc

David Pallmann said...

@RickAndMSFT, I'm not sure I can fully agree with you. Yes, it is true you can combine WAWS with the other areas of Azure (PaaS Cloud Services and IaaS Virtual Machines). But I'm describing these features individually, and WAWS itself is about 2-tier web sites. There are also more differences between WAWS and PaaS Web Roles than you mentioned, such as VM persistence.

Unknown said...

Hi,

Good Explanation.Can you please post some the safety measures working with Windows Azure.
Data Center Management