Where can I store my Data on Windows Azure?

So, You’re building a cloud app on Windows Azure are you? Where are you going to store your data? This is a question that comes down to architecture, scale and options. Considering I don’t know your architectural decisions, or how scalable your particular application, I guess that leaves me with only one topic to talk about, What are your options for storing data on Windows Azure?

Windows Azure is an open cloud platform which enables you to quickly build and deploy your applications using your existing skillset. This is reflected in the data options which are available for use on Windows Azure which are also hosted on Windows Azure.

Relational Databases on Windows Azure

Some Applications (or Developers) can’t live without a trusty relational database. We’ve got that.

MySQL

This option surprises many developers, but Windows Azure does have MySQL databases available for use.

MySQL is provided by a partner ClearDB who maintains multi-master and multi-master with multi-replica MySQL configurations. ClearDB combines advanced replication techniques, advanced clustering technology and a web service interface to provide MySQL Databases for your consumption.

If you create a Windows Azure Web Site using the Create with Database or From Gallery option in the Windows Azure Management Portal a Mercury sized database is being provisioned on your behalf.

MySQL Sizing Options

Pricing available on the Windows Azure Store on the ClearDB Website.

Package Name

Database Size

Max. Connection limit

I/O Performance

Mercury 20MB

4

Low
Venus 1GB

15

Moderate
Saturn 5GB

30

Moderate
Jupiter 10GB

40

High

MySQL on a Linux Virtual Machine

In addition to the ability to leverage a third-party service for using MySQL on Windows Azure, you can also leverage the new Virtual Machines feature. Follow the steps for setting up MySQL on an OpenSUSE Virtual Machine on Windows Azure.

Pricing for Linux Virtual Machines are available on the Windows Azure Pricing page.

SQL Database

Microsoft has created a cloud equivalent of SQL Server known as Windows Azure SQL Database (or SQL Database for short). SQL Database uses the same TDS Protocol as SQL Server which means all standard libraries or drivers [like the SQL Server Driver for PHP] work against SQL Database for Connectivity and Querying.

SQL Database Sizing Options

Pricing available on Windows Azure Pricing page under Data Management.

Database Size
100 MB
1 GB
10 GB
150 GB

As you can see above, SQL Database offers sizing tiers which acts as a starting point for your database size, additional database sizing between the tiers is offered at a discounted database rate as described in the SQL Database section of the Windows Azure Pricing page.

You may have also noticed that the maximum database size is 150GB, once you reach a database of this size it becomes necessary to shard your data using a technical known as SQL Federation.

SQL Server on a Windows Virtual Machine

If you need a large database (Scaled Vertically) or rely on a feature that is not currently present in SQL Database, it is possible to install SQL Server in a Windows Virtual Machine. Depending on the version of SQL Server you would like to use there are two great tutorials: Provisioning a SQL Server Virtual Machine on Windows Azure [which installs SQL Server 2012 from an image in the gallery] or Creating and Uploading a Virtual Hard Disk that Contains the Windows Server Operating System [which explains how to create a reusable operating system image, you’ll need to install SQL Server before running sysprep the VHD]

Unstructured Data (NoSQL) on Windows Azure

Unstructured Storage is becoming all the rage, which is understandable due to its ability to massively scale.

Windows Azure Table Storage

Windows Azure Table Storage is one of the three abstractions of Windows Azure Storage. Table Storage is an Entity-Attribute-Value model data store with a 100TB per account limit. Each subscription has 5 storage accounts by default, and more storage accounts can be added by calling customer support.

An entity in Windows Azure Table Storage is comprised of 3 required properties partition key, row key & timestamp and up to 252 additional properties. Properties can be one of the following data types Int32, Int64, String, Guid, DateTime, Double, Boolean or Byte Array.

MongoDB on Windows Azure

There are a few different ways that MongoDB is supported on Windows Azure which include in a Cloud Service, on a Virtual Machine or as a Service.

MongoDB in a Cloud Service

The creators of MongoDB, 10gen, have created a MongoDB installer which will install a MongoDB replica set in a Windows Azure Cloud Service. To do this they leverage a worker role in which their installer leverages a startup script to install the MongoDB Server. It also utilizes Local Storage as a cache before committing new transactions to Blob Storage.

To use the MongoDB in a Cloud Service configure and Deploy the MongoDB Installer.

MongoDB in a Virtual Machine

Obviously MongoDB can be installed on a Virtual Machine and can be exposed to the internet. There are two tutorials on installing a standalone instance of MongoDB on Windows Azure: Install MongoDB on a virtual machine running CentOS Linux in Windows Azure and Install MongoDB on a virtual machine running Windows Server 2008 R2 in Windows Azure.

If you would like to set up a highly available MongoDB replica set on Windows Azure, follow the instructions laid out in MongoDB on Windows Azure VM – Linux Tutorial or MongoDB on Windows Azure VM – Windows Installer,

MongoDB as a Service

Another option for MongoDB on Windows Azure is MongoDB as a Service provided by MongoLab. This service is [at time of writing] in preview and provides 500MB of storage for FREE. The MongoLab Preview is currently only available in the East US datacenter.

Preview Warning

We are pleased to be able to offer free databases running on Windows Azure. Be aware that both Windows Azure and MongoLab’s presence on Windows Azure are still in preview mode, and that these databases are not appropriate for production use. For example, we may need to take them down for maintenance from time to time without advance warning.

image

CouchDB on Windows Azure

Apache CouchDB is a JSON document database exposed over HTTP.

CouchDB comes with a suite of features, such as on-the-fly document transformation and real-time change notifications, that makes web app development a breeze. It even comes with an easy to use web administration console. You guessed it, served up directly out of CouchDB! We care a lot about distributed scaling. CouchDB is highly available and partition tolerant, but is also eventually consistent. And we care a lot about your data. CouchDB has a fault-tolerant storage engine that puts the safety of your data first.

BigCouch by Cloudant

Cloudant has expanded the base implementation of CouchDB in a new incarnation they are calling BigCouch. BigCouch as a Service is offered in the West US datacenter in a cluster Cloudant refers to Lagoon.

The Cloudant Data Layer collects, stores, analyzes and distributes application data across a global network of secure, high-performance data centers, delivering low-latency, non-stop data access to users no matter where they’re located.

BigCouch is chalked full of goodies including secondary indexes, lucene-based full text search, as well as built in replication and synchronization.

Cassandra on Windows Azure

Looking to build the next Netflix or Twitter? Run an elastic, decentralized and fault-tolerant Cassandra cluster on Windows Azure. Learn how to harness the power of Cassandra while a Node.js application in the tutorial Running Cassandra with Linux on Windows Azure and Accessing it from Node.js.

Choose your own Adventure

Have a favorite data store of your own? Why not try running it on Windows Azure? If you do, leave a comment below with a link off to a blog post explaining how you got it running.

Stay Cloudy my Friends…

Enabling PHP 5.4 in Windows Azure Web Sites

Much like many other developers, I like to live on the bleeding edge, learning new language features, using the latest tools so naturally one of the things I wanted to see in Windows Azure Web Sites is support for PHP 5.4. I’m pleased to be telling you today in this post that support for Bring-Your-Own-Runtime is now available in Windows Azure Web Sites.

Out of the box, Windows Azure Web Sites supports PHP 5.3 as you can see from the snapshot of the portal below. In this article I’ll explain how to enable PHP 5.4 in Windows Azure Web Sites.

Windows Azure Framework Support

Configure PHP 5.4 Handler Mapping in Web Sites

In order to enable support for PHP 5.4 in your Windows Azure Web Site, you will first need to create a Web Site.

If you haven’t already signed up for a Windows Azure account, get a 90 day free trial of Windows Azure which gives you access to 10 free Windows Azure Web Sites.

To create your first site, I would suggest following one of the many tutorials on the Windows Azure PHP Developer Center.

I’ve created my Windows Azure Web Site, What’s Next?

To bring you up to speed, I’ve created a Web Site using Quick Create, using configphp54 as the dns prefix for my Web Site.

Web Sites
Click on the Name of the Web Site [in my case configphp54] to proceed to the Details page for your site. On the details page you will see top level navigation items [DASHBOARD, MONITOR, CONFIGURE, SCALE, LINKED RESOURCES] listed. Click on DASHBOARD.

In order to be able to deploy files to the site, we’ll need to create some deployment credentials, you can create [or reset] your deployment credentials from the quick glance section of the DASHBOARD.

image

Click on create [or reset] deployment credentials to be prompted with a dialog box to enter your credentials.

image 
Fill out the user name, new password and confirm password to create your deployment credentials or simply the new password and confirm password to reset your password. Now your web site is ready for FTP or Git deployment.

Next, click on CONFIGURE.

At the bottom of the CONFIGURE page you will see a new section called Handler Mappings.

image 
Handler Mappings are a way to map a Fast-CGI script processors to file extensions in IIS. These script processors are typically console applications which means they may be able to accept additional command line switches. To set up a custom handler mapping you are required to set at least 2 of the three values, let’s quickly go into some more details around Extension, Script Processor Path and Additional Arguments.

Extension: This is the file extension which should be mapped to the Script Processor.

Script Processor Path: This is the field which specifies the absolute path to a Script Processor [in our case this will be php-cgi.exe]. The script processor’s binary and configuration files can be located anywhere within the application root directory which can be accessed using the D:\home\site\wwwroot path.

Additional Arguments: If the script processor supports additional command line switches which you may require, you can configure them in the Additional Arguments input box.

We’re only going to fill out the Extension and Script Processor Path to configure PHP 5.4. Enter the following values into the handler mappings section.

Note

After you type each line, click the checkmark at the end of the line to commit the value and add a new row. Clicking on the checkmark does not save the entries, a save button will show up in the command bar at the bottom of the portal.

Extension

Script Processor Path

Additional Arguments

*.php

D:\home\site\wwwroot\bin\php54\php-cgi.exe

Warning

wwwroot is publicly exposed to the internet which could potentially allow remote execution of executable files contained in wwwroot. By default IIS blocks access to the bin directory of any website or virtual directory, which is why it is safe to place the php runtime in the wwwroot/bin directory.

After you are finished, hit the save button that appears in the command bar to commit these settings.

Wait? Where do I get PHP 5.4 for Windows Azure Web Sites?

Before this site will actually work, we need to provide the php54 runtime in the path specified in our handler mappings settings. Download and extract the VC9 x86 Non Thread Safe zip file to the bin directory in your project

Note Your password is the password you typed while creating your deployment credentials above. This password is used for Git or FTP deployment. For WebMatrix, you can use the Publish Profile to load the configuration for a seamless publish experience.image

Trust, but Verify… (Thanks Horatio… Yeah!)

Upload an index.php file which contains a call to phpinfo() to the wwwroot folder.

If you browse to the site you will see that the site is in fact running with the latest version of PHP (5.4.7 at time of writing).

image

PHP does auto-discovery of the php.ini file by looking in known locations where it is expected to be placed, the first such place it looks is the directory which contains the script processor. This means that you will have access to your own php.ini file.

image

By Default, the PHP runtime does not have a php.ini file, it is packed with php.ini-development and php.ini-production. Rename php.ini-production to php.ini, open the file and search for fastcgi.logging and remove the preceding semicolon (;) which will uncomment the line fastcgi.logging=0. FastCGI Logging needs to be disabled (0) in the pipeline or it will return a HTTP 500 when you attempt to execute a script.

With Great Power, Comes Great Responsibility

Now that you own the runtime, you essentially own the experience and the security of the application. Be sure to follow the guidance on iis.net Best Practices for Configuring FastCGI and PHP to ensure optimal performance and security.

Stay Cloudy my Friends

WebMatrix 2: Available at a Web Platform Installer Near You

WebMatrix v2  hits the shelves yesterday so run out and download it now!. There are many additions to WebMatrix in this launch and I would like to take the time to describe a few of the things that may shock and excite you.

If you aren’t familiar with WebMatrix here is a quick blurb from the product page:

WebMatrix is a free and lightweight web development tool.
Create, publish, and maintain your website with ease.

What is new in WebMatrix 2?

It’s incredible how many features they can plug into WebMatrix and still have it be very lightweight and simple to use. Let’s take a look at some of the newly supported features of WebMatrix 2.

Intelli-Sense & Syntax Highlighting

Ok, so this might not necessarily be *new* to WebMatrix, but it has definitely been expanded. Many of you may be asking, what the $#@! is Intelli-sense? Intelli-sense is autocomplete on steriods, not only does it list the options for what you are currently typing, but it provides information around if what you’re typing is a method, constant or other variable type, it will also provide you with the method signature or additional information about the particular item you have selected in the list. There is intelli-sense and syntax highlighting support for the following languages/frameworks:

  • HTML5
  • CSS3
  • Node.js
  • PHP
  • ASP.NET MVC
  • Javascript
    • WordPress
    • Joomla!
    • Drupal
    • LESS
    • SASS
    • jQuery Mobile

    Yeah, WordPress, Drupal and Joomla! support, WebMatrix is making it easier to extend your favourite Open Source CMS by providing a quick reference to the built in methods of these framework applications.

    Community Oriented

    Now for something everyone can enjoy!

    Web Gallery

    Install a wide variety of Open Source projects directly from the Web Gallery including WordPress, Joomla!, Drupal and phpBB. New items are added to this list on a regular basis, so it could also be a great tool to discover new Open Source Projects.

    WebMatrix-Community

    Extension Gallery

    Another cool community aspect of WebMatrix is the extension gallery, which allows you to build custom extensions to WebMatrix. The extension gallery is already chalked full of great extensions including Git for WebMatrix, iPhone, iPad & Windows Phone Simulator.

    Mobile Friendly

    Mobile is all the rage right now, so having a tool not only helps you test on mobile device emulators, but actually gets you started with Mobile Friendly Templates and has auto completion for jQuery mobile, it’s like a match made in heaven.

    Cloud Friendly

    Last but definitely not least, the one thing you most likely come to my blog for, THE CLOUD! WebMatrix allows you to deploy to Windows Azure right out of the box. Of course this isn’t the only deployment option, but quite frankly, it’s the only deployment option I’ll be using. Within a few steps you can be publishing an existing site from your hard drive to Windows Azure Web Sites, or pull down that WordPress site you installed using the Windows Azure Gallery for a few quick changes.

    To Learn more about the cloud features, read Announcing WebMatrix 2 by Jonathan Guerin.