I get a generic server error on Azure fastCGI on accessing a blob storage.
The error is:
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
Below is the code. This code runs fine in local tests and all files uploaded on Azure as content work fine.
Can anyone please tell me how to debug and view the actual errors?
<pre><?php
error_reporting(E_ALL);
header('Content-type: text/html');
echo 'C2, Start';
require_once('Microsoft/WindowsAzure/Storage/Blob.php');
$client = new Microsoft_WindowsAzure_Storage_Blob(
"blob.core.windows.net",
"xxxxxxxxxx",
"yyyyyyyyyyyyyyy=="
);
$filename= getcwd() . '\folders.txt';
echo $filename . '<br>';
if ($client) {
$client->getBlob('setup', 'folders.txt', $filename);
echo 'Blob Load ok! <br>';
} else {
echo 'Blob Storage Error <br>';
}
echo ', END';
?></code>
thanks.
By default, Windows hosting servers display a generic error when any application generates an exception. We display a generic error because the detailed error messages allow a malicious user to obtain sensitive information.
To troubleshoot the error, you can modify your web.config file and specify that a custom error message displays. A custom error message helps you to locate the specific code that is causing the issue.
Use the sample code below to display custom error messages on IIS 7:
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
</configuration>
Multiple options here, but as a starting point ... can you just use a PHP try/catch and echo your error? While not the most elegant way, for this simple issue, would most likely be the simplest.
try {
if ($client) {
$client->getBlob('setup', 'folders.txt', $filename); echo 'Blob Load ok!';
}
else {
echo 'Blob Storage Error;
}
echo ', END';
}
catch(Exception $ex) {
echo $ex->getMessage();
}
You can try setting PHP to show all errors and IIS show process the error pipe without mod and show you the information.
You should deploy a php.ini file with display_errors=On
Google/Stack search for php.ini on Azure if you are unfamiliar with how to do this.