I'm new to azure. I am using azure php sdk to run my apps. So far I got the tutorials going for my local machine. When I try to run it on the cloud I get an error. Here are the details:
My simple PHP code:
require_once('Microsoft/AutoLoader.php');
print 'Hello World';
This code runs perfectly on a local machine. When I try to run it on the cloud I get this error:
Server error
The website encountered an error while retrieving http://link234235345345.cloudapp.net/. It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this webpage later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
When I try removing the import statement like this:
print 'Hello World';
It runs perfectly on the cloud.
My question now is how do I properly import the autoloader? I think the location is different on the cloud. Does this mean that everytime I develop locally I have to change address always for my imports when bringing it on the cloud?
The autoloader should have been imported with the package. To get the exact error from the PHP log (Which will tell you if that is, in fact, the issue) you need to enable Remote-Desktop (RDP) for your web role.
http://azurephp.interoperabilitybridges.com/articles/enable-remote-desktop
RDP into the web role instance and locate the path to the php error log from the php.ini file in the PHP installation folder. The error log should contain the exact error.
Most likely the Microsoft SDK library was not found. Depending how you made it part of your application the location of the library is probably different then your local setup.
If you use composer to add the SDK to your project, you need to instruct your deployment to install composer packages after code updates.
In all other approaches I can only suggest to reference the directory using the __DIR__
global in your include statement:
require_once __DIR__ . '/../library/Microsoft/autoload.php
I hope this helps
Azure web app is great for running PHP applications, but requires a little more preparation to have it do all the things you want.
If you want to use Redis in your app, I can highly recommend using the latest PHP version. You can accomplish this by creating a folder php/
in your project route where you unpack the latest PHP for Windows version from https://secure.php.net/downloads.php. In that same folder you can drop in the latest Redis PECL extension that you can download from http://pecl.php.net/packages/redis (DLL).
The Azure SDK you mention is not relevant for accessing Redis on Azure, it’s used to access core Azure services like Blob Storage, Document Search, etc...
I’ve been running PHP apps on Azure successfully since 2008 and have seen that it’s a great solution to run complex web applications build with PHP in the cloud. So if you’re still struggling with the issue, hit me up and I’ll work out a more detailed guide how to get started.
Good luck!