Chapter 5

Working with Other Flavors of Windows Azure Web Sites

IN THIS CHAPTER:

  • Discovering the types of web apps you can install from the Gallery in Windows Azure Web Sites
  • Installing and configuring an open source bulletin board through the Azure portal
  • Getting a copy of your website to maintain locally and redeploy to the cloud

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.

EXPLORING APPS IN THE WEB SITE GALLERY

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:

  • App Frameworks — Foundations for application development backed by active communities and great documentation
  • Blogs — The fundamentals you need to create and host a blog site on Windows Azure
  • CMS — Going beyond a straight blog, complete management systems to compose sites with multiple authors and varying levels of extensibility
  • E-Commerce — Offers a quick way to implement shopping cart functionality and content pages with an eye to payment gateways and social-enabled commerce
  • Forums — Simple starting points to enable users to interact with each other on your website
  • Galleries — Offers comprehensive CMS capabilities as well as transcoding and thumbnailing services to share media and its metadata on the web
  • Templates — From boilerplate, no-frills documents to turnkey multi-page sites that include membership in a variety of languages
  • Wiki — Enables you to easily add crowd-sourced documentation in the style of several well-known sites

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.

SELECTING A TEMPLATE

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.

Sample Implementation and Publishing Walk-Through — phpBB

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!

CREATING THE SITE

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:

1. Open your Azure portal by navigating to http://manage.windowsazure.com/ in your web browser and sign in with your credentials.
2. To create a new website, click New in the command bar.
3. Select phpBB from the Gallery. It is easier to find the phpBB template in the list of available apps if you limit your selection to the Forums category.
4. Name your site and configure database access. You can pick any unique name that is not in use on azurewebsites.net, and choose to configure an existing database server or create a new one. Take note of your server name and your database name, and choose a username and password you’ll be able to remember, as you will need them later.
5. Confirm your database selection, or complete the information to create a new server and database. If you’ve chosen an existing server instance, you may need to specify the administrative username and password you used when you created the server (it depends on the type of database server that you’re connecting to); otherwise, simply name the database and create a new user.

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.

Configuring the Board

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:

1. Start the configuration process on the forum. You can either click the Setup link mentioned in the previous section or browse to your site directly in a web browser. Without an active configuration in place, phpBB assumes that the first person accessing the site is the owner and initial administrator.
2. Click the Install tab. Because you are creating a new forum, you’ll follow the script to get a new instance running. When you install new versions, you will be able to upgrade them in place through this installation process from the Convert tab.
3. Click “Proceed to next step” on the welcome screen. There is a bit of text there spelling out the requirements, but your database information and everything else you need from a technical perspective is provided through Azure.
4. Click Start Install from the requirements overview. You might need to scroll down to see the button. Although your site will run without modification, it may be interesting for you to review the checks that are done and read some warnings about features you’ll have to install for complete functionality.
5. Enter your database information and click “Proceed to next step”; and after a successful connection to the database, click “Proceed to next step” again. Be sure to specify the MSSQL Server 2005+ [Native] option for the database type. Enter your server hostname, which will be something similar to “g4si46f1c9.database.windows.net,” and fill in your database name and credentials. These are the details you recorded in step 4 from the previous section. You can leave the port number blank, and the prefix can be left as the default value of phpbb_.
6. Choose an administrative username and set your credentials. You will also need to provide an e-mail address.
7. Accept the administrator details, then click through the confirmations and options accepting the defaults. You can leave all the default values and complete the installation by continuing to click the “Proceed to next step” buttons on each of the subsequent pages until the final confirmation.
8. Now that you have completed the installation process, the next step is to delete the install folder so that the site will begin to function as designed. The last page of the wizard has several delete links; you can click any one of them.

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.

Working Locally with Project Files

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:

1. Click the WebMatrix icon in the command bar. You’ll need to be logged in to your Windows Azure Portal. Either select the site from the list of items in your account or navigate to the site dashboard, where the WebMatrix icon appears.
2. Download any required dependencies to run the site locally. Be sure to review any licensing agreements and then proceed to install any additional required components to give yourself the richest development experience on your machine.
3. Select the option to work locally in WebMatrix. Part of the download process lands inside WebMatrix and prompts you to pull in the site from the cloud source. This will make a copy of the site and download the database as well as any support files related to phpBB so that you can optionally run the site directly from your machine.
4. Navigate to and open the overall_footer.html file in your project. This file is used to render the footer for all pages on the site outside of the administrative control panel and is located in the stylesprosilver emplate directory.
5. Add the following code as the last element in the page_footer div in the file. The page_footer element contains two divs: one attributed with a class called navbar, the other with a class called copyright. You’re adding a third div with the same copyright class:
   <div class="copyright">
       Running on <a href="http://www.windowsazure.com">Windows Azure Web Sites</a>
   </div>
6. Save the contents of the file. This will save your site locally.

You’re now ready to sync your site with Windows Azure.

Publishing the Customized Site

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:

1. Click the Publish button in WebMatrix. This button is displayed in the UI by default when you are editing the local version of the site, but if you have navigated through the software you may need to return to the Home ribbon to see the icon.
2. One of the benefits of the Publish mechanism is that only those files that have been added or modified are sent to the server. At this point, you have the option to review the files that meet these criteria (technically known as the computed difference). For example, if you have altered only the overall_footer.html page, you’ll just see one file in the review stage.
3. Confirm your selected files and click Continue to publish to Azure. This will move any selected files — in this case, your newly adorned footer — up to your instance of phpBB in your account.

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:

1. Navigate to your website. There are many ways to do this, but the easiest might be through the publishing confirmation in WebMatrix. You can type the name of the site directly in the browser, or you can click any of the links in your site’s dashboard in the Azure portal.
2. Log in to the site and enter the Administration Control Panel (ACP). There is a link at the bottom of each page to access the administrative area of the site, and you will be prompted to confirm your credentials as you enter.
3. Go to the template management area of the site. To get there, click the Styles tab at the top, then click the Templates link on the left-hand side of the page under the heading Style Components.
4. Clear the site cache. Under the Actions column of the Prosilver template, click the Refresh button and accept the prompt to clear the cache.

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.

Moving beyond the Basic Set Up

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.

SUMMARY

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset