IN THIS CHAPTER:
The prestige is a pivotal point in a magic act when the magician takes an already impressive trick to the next level and shows the audience something they've never seen. The folks working on the Windows Azure team have had plenty of wins over the last year: a newly designed interface that makes configuration, deployment, and scaling more accessible; streamlined publishing options; and improved CLI integration, to name only a few. As Microsoft continues to improve upon its cloud efforts, Windows Azure is in many ways becoming the company's “prestige.”
If you're from outside the .NET camp, you've likely been wondering how some of the things in the peripheral view of the portal come into play in your development space; and if you're a .NET developer (and you have been paying attention to the Windows Azure world), you might have seen hints that Azure will contain functionality that is intended for people outside of the Microsoft world.
And you'd be correct.
It turns out that, when it comes to Windows Azure, the “dot-netters” of the world aren't the only ones who get to have fun. Azure has embraced the open source community and made many non-Microsoft technologies feel right at home when running on Windows Azure, even from within alternative and competing development environments.
If you're crossing over from another community, this is the chapter for you, replete with the information you need to bring your site to the cloud. If you're a regular Visual Studio user, this chapter will give you a glimpse of how things roll for your development brothers and sisters with a different gait to their walk.
You'll find a growing number of templates in the Gallery for Windows Azure Web Sites, handily categorized. The list of projects you can use to kick-start your own is diverse and offers everything from bare-bones starter sites to rich applications with dynamic content.
Here is a sampling of the current categories at the time of writing that you'll find as you create an app-based site in the portal:
Pick your language, pick your open-source project, or pick your empty document in a language of your choice and get going. The Azure portal provides a wizard-style interface to select a template; and if there are additional steps to perform, such as associating a database, it will help you through those steps as well.
The list of web apps available continues to grow, and the projects in the list are updated on a regular basis. When you add a new web app from the Gallery, the portal displays a great template browser, illustrated in Figure 5-1, that enables you to read an overview of any of the templates.
At the time of writing, there were nearly three dozen templates in this expanding list, all of which provide a good opportunity for exploring a project you haven't worked with previously, or perhaps one that you haven't revisited in quite some time. Even if you have only a trial membership or you're registered for pay-as-you-go service, Windows Azure Web Sites gives you 10 free websites so that you can easily experiment with the ones you would like to learn more about. The following sections demonstrate how you can hop on board with a popular open source forum.
The Internet has long been adorned with bulletin boards, which shifted from dial-in services to widely available conversational “water coolers” throughout the 1990s to a point where now it's odd to see a community-facing site that doesn't include some kind of social aspect. While other social networking sites have largely swallowed up forum users and would-be forum users, there is still a place on the web for subject-focused conversations, particularly if you need to moderate the content yourself.
For more than 12 years, the open source phpBB forum has been available for anyone to use on their domain to provide chatter space for their users. Its comprehensive administrative control panel, shown in Figure 5-2, is revered for its flexibility and adaptability to meet the needs of many sites. It's no wonder that hundreds of thousands of installations have been served up to millions of daily users, making phpBB the most widely used open source forum software on the web.
Found under the Forums category in the Gallery, you can easily create a site in Windows Azure Web Sites that features the phpBB software — and based on my personal experience, this is far easier to do now than it was 12 years ago!
As with every website on the Internet, you're going to need to carve out a bit of cyberspace for your bulletin board. This is done through the portal, as it has been in previous chapters, where Windows Azure Web Sites takes care of setting aside disk space, registering your subdomain, and creating the appropriate web server mappings:
When you've completed the preceding steps, Windows Azure will happily go off and provision the assets needed to bake the site for you. It creates the site, deploys the codebase, optionally provisions a new database server for you, adds a new database to your server, and finally creates a link between your database and your website for easier management of resources down the road.
When the server has done its duties, it returns a message similar to the following in the notifications pane in the command bar:
The deployment of web site “your_site” succeeded. View the connection information on the Configure page. To set up the application now, click Setup.
Here, you can click the Setup link to begin the process of going live with your site.
Once the template is applied and your site is spun up, there are still a few more steps to get it running like the one in Figure 5-3. The one-time configuration provided by phpBB walks you through these steps quite easily. Follow the onscreen prompts to complete your setup with the database settings you captured in the previous section. If you did not save or write down your database settings, you can get them with a little help from the website dashboard in the portal, where you'll find the View Connection Strings link under the Quick Glance section:
Your site (a sample of which is shown in Figure 5-3), is now running and you can start posting or inviting folks to sign up.
The default site looks great and works fine, but don't you want to customize it, just a little? Of course you do, web warrior! In Chapter 2 you had a chance to work through several methods for pushing a site to the cloud. Now, you'll use one of those methods — WebMatrix — to pull the contents of the site down locally and work from your machine.
There is more to a website than just a file, however, and you'll need to get the database down and onto your system as well. In addition, don't forget that this is a PHP site, so you will have to configure your machine to run PHP. The easiest way to get the job done and get the site up and running locally is actually through the Windows Azure portal.
When you navigate to your site's dashboard, recall that there is a WebMatrix button in the command bar of the portal. Clicking this button not only enables you to open your site in WebMatrix, but also pulls down any other dependencies you need to run the site locally. You can do that now, and prepare to edit the site footer, where you'll let everyone know about your newfound cloud skills:
<div class=“copyright”> Running on <a href=“http://www.windowsazure.com”>Windows Azure Web Sites</a> </div>
You're now ready to sync your site with Windows Azure.
With your changes implemented, it's time to see the fruits of your labor live and running from within your website on the cloud. In the case of phpBB there are some additional steps to enable your template, but activating your changes in the forum itself is a separate process from pushing your code. You'll first get the changes out into the cloud using the following steps:
NOTE Caching in phpBB introduces new files into your local project if WebMatrix has started running your site locally before you publish. This results in many additional files that look like they need to be uploaded to Windows Azure, but you can ignore any files in the cache directory; these files will be recomputed on the server.
Next, you need to activate the new version of the template. phpBB creates a cache at startup time that stores a pre-rendered version of files from your template, and the cache needs to be cleared so that the files can be rebuilt. This would happen automatically if you used the built-in editor in phpBB; but when you save the files to disk or publish them through any other means, phpBB doesn't know that it needs to invalidate the cache and rebuild. So you need to help the site out:
With the template updated and the cache cleared, phpBB will recompute your footer on the next visit to the site. As shown in Figure 5-4, the site footer now tells all your visitors where the site is hosted.
In this fashion you can add new files, modify graphics such as for the site logo, or modify additional templates and easily move them back into the cloud-hosted site.
The ideas described here have been to simply use the Windows Azure Portal to get the site kick-started and running in the cloud. Using the site template ensures that database resources are linked and critical aspects of your configuration are properly set.
You don't have to edit the template locally, as phpBB offers a way to edit files directly on the site. However, editing locally does have its advantages — namely, a better development experience in a product like WebMatrix, but also the capability to operate under your source control suite of choice. In fact, the Source Control ribbon in WebMatrix enables you to add the project to Team Foundation Server or run Git init on the project directory. In addition, with source control in place, you're able to commit changes to the portal and manage check-in-based deployments, as covered in Chapter 3.
All of these reasons make a compelling argument to use Azure to help spin up a site using a Gallery template but take the steps needed to work on your site locally.
Open source projects are growing in diversity, popularity, and quality; and they can serve as a great starting point for many projects that you might like to take on. The Gallery in Azure Web Sites enables you to easily browse and select a template from a growing list of categories to begin your efforts, and includes everything from shell projects to fully operational websites.
Whether you've started your site from scratch or elected to use one of the templates provided through the Gallery, you've seen how the cloud can also be very local. Some great tools are provided for those just getting started, and veterans can continue to use their preferred editor to modify their project, update site contents, or add new files and ultimately publish their changes to the cloud.