Getting Started Building a PHP Azure App
If you are a serious Windows developerĀ you will by now have come across Windows Azure Platform. Windows Azure Platform, which is an Internet-scale cloud services platform hosted in Microsoft data centers, is currently (as of January 2010) open to developers and beta testers and will go into a pay-based model starting from February 2010.
Why Azure?
This is a great opportunity for developers, particularly those who, like our company Project VeriPage specialize in online tool development. The particularly attractive feature of Windows Azure is that now you can have a subscription based model for your cloud computing solution seamlessly without having to develop a custom solution.
The other advantage of Azure is that there are custom SDKs available for all major development languages – for example, Java, PHP and Ruby. So, no matter whichever of them you use for your development, they all share a common methodology.
Baby Steps
When we first decided to develop our first application on Windows Azure Environment (WAE), (let’s just say it was a real-time finance related application), there were several challenges that we faced.
One of the first things that we encountered was to familiarize ourselves with the proper terminologies in WAE. ‘AppFabric’, ‘Blobs’, ‘Web Roles’, ‘Service Management’ – is there any end to all those new terms?
Very soon we learned, as with any new technology, the sooner you make yourself comfortable with these new terminologies, the faster you can develop your application.
Although there are a number of online discussion forums that provide WAE-related help some of which are monitored by Microsoft technical teams, for authenticity we headed to MSDN site for Azure (http://msdn.microsoft.com/en-us/azure/default.aspx) to learn about the new terms and techniques. This, in retrospect, saved us a lot of time.
The ‘How Do I’ page (http://msdn.microsoft.com/en-us/azure/dd439432.aspx) on MSDN was also very useful.
Getting Started
Learning the terms upfront is not the only thing that worked out to our advantage.
We registered with the Microsoft Connect site (https://connect.microsoft.com/default.aspx) to get the community support to develop our application as soon as we could. This is also needed if you already do not have a development token for Azure or SQL Azure. The process involves acquiring a Live ID (if you have a Hotmail account, you are covered), apply for development tokens and then wait for few days. Once you get the token redeem it at the Windows Azure Portal at http://windows.azure.com.
Essential Downloads
There are two ways to develop your application for WAE. You can develop it in your local machine or on the production Windows Azure Environment. We chose to do the later.
We downloaded the Azure SDK (from http://www.microsoft.com/downloads/details.aspx?FamilyID=6967ff37-813e-47c7-b987-889124b43abd&displaylang=en). For us, the development was done with PHP and we also downloaded and installed PHP SDK for Azure (from http://phpazure.codeplex.com/) (see screenshot below).

Last but not the least, since we used Eclipse (Galileo version) for development, we downloaded Windows Azure for Eclipse (http://www.windowsazure4e.org). This specific site provided very useful and seamless tools for anyone who is already familiar with Eclipse and now would like to develop apps on WAE.
None of these downloads was difficult to install or needed any intervention from our side. With these downloads fully installed, we were ready to start our first application developed on Azure.
A Few Words about our App
Our specific application was, as mentioned earlier, a legacy real-time application for finance related use. For it to work at all you must be connected to the internet – all the more reason to port it to WAE. Since it was heavy on the online computation, the legacy version used PHP for the implementation.
Another specific aspect of the application was it did not use any data storage. All computations were done on the fly and the result is served after those computations to the user. This makes it particularly easy for the app to be ported on WAE as one major issue for migrating applications to Azure is to change the data storage routines to use Azure data storage.
1. We started Eclipse with Windows Azure PHP Project plug in installed.
2. Selected Window -> Open Perspective -> PHP.

3. Created a new PHP project: File -> New -> PHP Project.
4. Change the Eclipse perspective from PHP to PHP Windows Azure: Windows -> Open Perspective -> Other… And then select PHP Windows Azure.

5. Create a new Windows Azure Project and set the ‘Data Storage’ option to none.

6. In the PHP Explorer, the solutions are automatically created.
7. We added the files that we wanted to port by right-clicking the WebRole tab.
8. Then we created a package – ‘Windows Azure’ -> ‘Publish Application to Windows Azure Portal’. This is the all encompassing step to generate the package. It automatically opens a browser window to let us sign up on the Windows Azure Portal and upload the packages.
Building the App
The steps to develop an application using the above tools are described in great detail in many of the resources mentioned earlierĀ and are not repeated here, but I should mention that we particularly liked the Labs and descriptions given on ‘Windows Azure for Eclipse’ site.
1. First to re-state the rules: you will need Windows Vista with SP-1/Windows Server 2008 or later to do any development on WAE. You cannot develop an app for WAE on XP (or moreĀ understandably, on Linux). There is no way around it. It is written as part of the ‘System Requirements’ for every download mentioned above and though obvious, this is something that we saw many developers tripping on. Similarly, you cannot use the production platform without a token.
2. If you are using PHP for your development, make sure Eclipse shows no errors in your code under the ‘Problems’ tab before you generate any package. This may seem obvious, but many people tend to ignore this.
3. If you have multiple files in PHP (or HTML) that are required for your application, make sure they are all under the same webrole before you proceed with the package generation part. You can always a add new file by right clicking the webrole and then selecting New -> PHP File.
4. You can and should change your ServiceConfiguration.cscfg file as per your requirements. Although the default one that is generated will make your application functional, you can modify, for example, the instances field among other things as per your needs.

Conclusions
This article has attempted to show you the resources that you can avail today to make your development process on WAE faster. It also shows some of the potential issues that a first-time developer on WAE may encounter. When I hope the article has been useful for you, obviously, this is not necessarily an exhaustive list of resources or solutions.
Array




27. Jan, 2010 








No comments yet... Be the first to leave a reply!