Over the past two weeks I’ve been frantically developing Twitter Sentiment Engine, my entry for the PHP Azure Contest and my university final project. With the functionality for v1.0 nearly complete I thought that it would be a good idea to get the application on Azure. I could then diagnose any platform specific bugs that may occur and have a demo version of the project for others to critique.
That was the plan today at 8am when I started trying to deploy the application. Over the course of the day I hit a number of snags and still haven’t been able to get my application ‘in the cloud’.
My first attempt utilized the steps I outlined in my previous post on how to deploy a Zend Framework application on Azure. Also I previously set up an SQL Azure instance, described here, to use as data storage for the application.
To summarise, I fired up the Azure CL Tool, pointed it at my application and waited while the tool packaged my application ready for uploading to azure. I also selected the option to run the application on the Dev Fabric so I could test the app before uploading it. The tool built the App and it ran fine on DevFabric. I expected in a few minuets time to have a fully functional application on Azure staging however I encountered my first issue shortly after uploading the package using the Azure management portal.
After the package uploaded and the web role was started successfully I went to the index page of my application. The holding page I had created displayed correctly. However on trying to access any of the api URLS a generic IIS7 500 custom error page was displayed. These pages are deliberately vague and offer no information as to what the error condition is. Great for production, terrible for me right now!
On a traditional development I would log into the box serving the application and review the error logs however I could not find a mechanism for doing this in the context of Azure. Instead I decided to view errors on screen, this would mean having to remove the custom error page and get at the underlying PHP error.
Removing Custom Error Pages On Azure Using web.config
1) Open your web.config file (usually located in projects source directory or the route of the site.
2) Add the line <httpErrors errorMode=”Detailed” /> within the <system.webServer> tags
3) Re-upload your project to Azure
After applying the changes above and re uploading the application to Azure I was able to see the real cause of the problem. Doctrine2 was unable to locate the sqlsrv driver for php. In order to verify that the driver wasn’t loaded I appended a phpinfo() call to the error page Zend Framework serves in the event of an application error. Unfortunately this involved another packaging and re-uploading of the whole application (including libraries). A process which I clock at between 30 – 40 min including packaging and uploading.
The phpinfo confirmed that the module was not loaded (no pdo modules were). This suprised me as it was my understanding that when you ran the packaging tool and specified the location of your PHP run time it to was uploaded to Azure also. I also checked the php.ini file in the Web_Role folder generated by the packaging tools. At the bottom of file listed with all the other extensions was ‘extension=php_pdo_sqlsrv_53_nts_vc9.dll’.
At present this is the bug that is holding me back from launch. Up to know the Microsoft team have been really supportive. I hope they can help again as I’d really like to get application in the cloud asap! If any one has ideas or thinks they could help please comment.
Platform Evaluation
My first experience in actually launching a full application on Azure hasn’t been very successful. I have some critique and questions:
1) Packaging and uploading my application takes roughly 30-40 min. In this debugging stage this puts an unacceptable amount of time between the opportunities to try fixes to the problems I’m encountering. I’ve been told it’s possible to move libraries to blob storage but haven’t yet been able to fond a good tutorial illustrating this.
2) I cant find a good tutorial outlining how to set up access to the PHP error log.
3) A related issue: I’m trying to launch my application on a Extra-Small compute instance. Ive followed the instructions here and altered the service definition file in the source directory of my project. When uploading this to Azure though I notice the instance is still given as ’small’. I’d like to utilize the 750 hours of ExtraSmall compute on offer.
Tags: #phpazurecontest, PHP
[...] Launching My PHP Application On Azure: Take One [...]