How to view actual error on Azure fastCGI?

2019-05-26 02:24发布

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.

3条回答
贪生不怕死
2楼-- · 2019-05-26 02:53

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();
}
查看更多
爷的心禁止访问
3楼-- · 2019-05-26 02:53

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.

查看更多
家丑人穷心不美
4楼-- · 2019-05-26 02:55

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>
查看更多
登录 后发表回答