PHP 5.4 Now Native in Windows Azure Web Sites

A while back I wrote a blog post on Enabling PHP 5.4 in Windows Azure Web Sites, when we enabled the ability to bring-you-own-runtime to Windows Azure Web Sites. This is still a valid solution if you would like to manage your own PHP.ini file, or if you would like to ensure that you are using a specific build of PHP.

It’s exciting to announce that Windows Azure Web Sites now has PHP 5.4 ready to be enabled in your Web Sites.

Even though PHP 5.4 is available PHP 5.3 is still enabled by default.

image

Enable Native PHP 5.4 in Windows Azure Web Sites

After Creating a Windows Azure Web Site, navigate into the Web Site details page and select the CONFIGURE tab. Under the framework section you will see PHP VERSION, select the box containing 5.4, it will turn purple notifying that there is an unsaved change.

image

At the bottom of the browser viewport you will find the TASK DRAWER, which would have changed to include a SAVE button. Click the SAVE button to enable PHP 5.4 for your Windows Azure Web Site.

image

Once the change has been saved, you’ll be greeted by this nice little success notice.

image

Finally, you will also notice that the purple indicator has now changed back to blue on the PHP 5.4 box.

image

You are now ready to deploy PHP 5.4 applications to Windows Azure Web Sites.

Happy Clouding!

Windows AzureConf is Tomorrow!

Windows AzureConf

Three years ago, I began learning about this thing called “The Cloud” at that point in time I made a decision, much like I made as a teenager to get into Web Development in the first place. The thought that lead me down this career path was “Huh, this web thing is really going to take off, I need to be a part of it.” When I heard about Cloud Computing a similar thought ran through my mind, “Wow, this cloud thing is really cool, this is definitely the way of the future.

A year into working with Windows Azure, I urged other developers to start researching the cloud [Get Started for Free] as it was still early enough to be ahead of the curve and set themselves out from the rest. Enter Windows AzureConf.

I cannot say for certain if I influenced any of these individuals in particular , but what I can say is they have also identified that the Cloud was future. Featuring a Keynote from Scott Guthrie (The Gu) as well as presentations from the Windows Azure Community drawing from their own Real-World experience with Windows Azure.

Join us for Windows AzureConf

In June we launched a number of additional features and services in to Windows Azure’s offerings, since then we have added a great deal more as highlighted in Satya Nadella’s Day 2 Keynote Address at Build.

What will be covered at Windows AzureConf

Windows AzureConf will cover a wide variety of topics including:

  • HTML5
  • WebSockets
  • Windows Azure Media Services
  • Deployment
  • Keeping Costs low
  • SignalR
  • Windows Azure Mobile Services
  • Continuous Delivery
  • Building Cloud-Scale Applications
  • Node.js
  • Compliance
  • Messaging Architectures

How can I get started?

There are a number of ways to get started with Windows Azure including the Windows Azure Training Kit, tutorials on WindowsAzure.com and of course reading the blogs of our community members:

Speaker Name Twitter Blog
Andy Cross @AndyBareWeb blog.elastacloud.com
Sasha Goldshtein @goldshtn blog.sashag.net
Rick Garibay @rickggaribay rickgaribay.net
Mihai Tataran @mihai_tataran www.avaelgo.ro
Eric Boyd @ericdboyd www.ericdboyd.com
Panagiotis Kefalidis @pkefal www.kefalidis.me
Michael Collier @MichaelCollier www.MichaelSCollier.com
Magnus Martensson @noopman magnusmartensson.com

Find more great Windows Azure Community Members on the MVP Site.

Windows Azure Training Kit – October 2012

The moment that you’ve all been waiting for has come, the October 2012 drop of the Windows Azure Training Kit has been released! This release is rather significant and I’ll get into the details in a few minutes, but first I wanted to call out the Windows Azure Training Kit page on WindowsAzure.com.

Special Thanks to the WindowsAzure.com team for updating the Windows Azure Training Kit page.

image

What’s new in this Release?

The October 2012 update of the Windows Azure Training Kit includes 47 hands-on labs, 24 demos and 38 presentations designed to help you learn how to build applications that use Windows Azure services. The October update includes updated hands-on labs to use the latest version of Visual Studio 2012 and Windows 8, new demos and presentations.

Presentations

We received a lot of requests to add speaker notes in the slide presentations. I’m happy to announce that we have included speaker notes necessary to support the majority of sessions in the Agendas which are outlined on the Agendas section. The following presentations have speaker notes to aid you in delivering a session:

Foundation

DevCamps

Localized Content

We have scene how excited the community was about mobile services, so we have created new GitHub organizations to host localized versions of the Mobile Services Presentation.

Hands-on Labs

September marked the launch of Visual Studio 2012 RTM. How do we ring in this celebration? We’ve converted a number of Hands-on Labs to support Visual Studio 2012. In addition to this, we wanted to ensure that you were properly supported for running community events, so we have ensured that the Hands-on Labs will work with Visual Studio 2012 Express Editions just incase you or your audience do not have a license.

Labs available for use with Visual Studio 2012

New Labs page Layout

As the number of labs has increased, we wanted to provide a nice simple way of discovering the provided hands-on labs. The page is divided now into VS2012, VS2010, Open Source, Scenario, and All [which is the classic layout with the ability to Navigate by Service.]

Windows Azure Training Kit Hands-on Labs

Demos

You may not have noticed in the August 2012 REFRESH but we shipped a few demos. You might not have noticed this because we didn’t have a navigation page for you to browse them, they were just sitting around on your hard drive if you were adventurous enough to check.

We’ve added a landing page now which will help you navigate and discover the demos which we have packaged for use with the presentations.

image

Available Demos

Contribute

GitHub - Codercat

One of the nicest things about the Windows Azure Training Kit is that it is open source and available on GitHub. This enables you in the community to Report Issues or Fork and either extend the solution or commit bug fixes back to the Training Kit.

You can find out more details about  the training kit from our GitHub Page including guidelines on how to commit back to the project.

Happy Clouding!

Windows Azure Cloud Service or Web Site: Where am I Deployed?

Recently, I came across someone trying to figure out where their code was deployed between Windows Azure Web Sites and Windows Azure Cloud Services. There are many things that you may want to wrap discovery code around between deploying to Cloud Services and Web Sites. One such example that comes to mind is use of LocalStorage in Cloud Services over writing directly to disk in Web Sites.

Non .NET Example with Environment Variables

In Non .NET Languages such as PHP or Node.js you may not have a standard configuration location or you may find the implementation of Environment  Variables more convenient. In a past article I outlined how to read App Settings from the App Settings section of the Windows Azure Management Portal, which explained that App Settings configured in such a way are exposed as Environment Variables.

Cloud Services also have a way to configure custom Environment Variables in the Service Definition (CSDEF) file which is packaged up with a Cloud Service Package (CSPKG). Considering both Cloud Services and Windows Azure Web Sites enable you to expose Environment Variables this is consistent way to share information in either deployment method.

Configuring Environment Variables in Web Sites Portal

Configuring Environment Variables in Cloud Services


Environment Variable in Action

PHP


Node.js


ASP.NET Example using Web.config

In ASP.NET there is the concept of a web.config file. This is an xml based file which is used for storing configuration settings which are specific to a deployment. It is easy to pivot on environment by providing transforms of the web.config file. Let’s assume we have 3 environments Local, WebSites and CloudService.

This will yield three configuration transforms which upon build will roll up to the base web.config:

  • web.local.config
  • web.websites.config
  • web.cloud.config

Creating an App Setting

An App Setting is a Key/Value pair configured in the <appsettings /> element within the web.config file.

Web.config

Application Configuration File

We’ll set this appsettings to a value appropriate for debugging.


Web.local.config

Configuration Transform

We will provide a replacement element for the appsettings for our local test environment.


Web.websites.config

Configuration Transform

We will provide a replacement element for the appsettings for Windows Azure Web Sites.


Web.cloud.config

Configuration Transform

We will provide a replacement element for the appsettings for a Windows Azure Cloud Service.


AppSetting in Action


Conclusion

Depending on your development language or your scenario [as the Environment Variable route would work for ASP.NET as well] you can quickly and easily setup a way to verify which Environment you are deployed to be it Local Test, Windows Azure Web Sites, Windows Azure Cloud Services or any other environment you may have.

Stay Cloudy my Friends…

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