我开发了一个 PHP 脚本,它可以生成简单的财务报告并通过 SMTP 发送(使用 PHPMailer 库)。
我尝试使用 Azure Web 作业托管和执行该脚本,但不幸的是,每次运行该作业时都会失败。
WebJob 位于 Azure 上的 wwwroot\App_Data\jobs\triggered\send-sales-report\send_sales_report.php
。
脚本内容如下;可以看出,该脚本导入了许多其他脚本:
<?php
try
{
include "./../../../../inc/class.EmailMessage.inc";
include "./../../../../E-Mail.php";
$message = new EmailMessage('sales_report', array());
SendOrderEmail('Sales Report', $message->render(), '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="036d626e6643666e626a6f73716c756a6766712d606c6e" rel="noreferrer noopener nofollow">[email protected]</a>', 'Recipient Name');
}
catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>
另外,上述文件的目录结构如下:
wwwroot
|___App_Data
|___jobs
|___triggered
|___send-sales-report
|___send_sales_report.php
|___inc
|___class.EmailMessage.inc
|___emails
|___sales_report.php
|___E-Mail.php
当我使用 Azure 门户(手动和按计划)运行 PHP WebJob 时,它失败,退出代码为 255;但是,当我使用 Azure 上的 Kudu 控制台执行脚本时,它工作得很好。另外,我也在本地复制了运行环境,运行良好。
非常感谢任何帮助。
最佳答案
我建议您为您的应用启用 PHP 错误日志。创建 .user.ini
文件并向其中添加以下内容:
log_errors = on
引用这篇博文:Enable PHP error logging
PHP 错误日志的默认位置为:D:\home\LogFiles\php_errors.log
这应该有助于进一步进行。
关于PHP Azure WebJob - 失败并退出代码 255(但在 Kudu 上工作正常),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45324500/