无法在具有辅助角色的开发人员模拟器上部署PHP

时间:2012-06-13 14:03:25

标签: php azure azure-worker-roles

我使用Eclipse和PHP插件来创建和配置我的PHP项目,以便在Windows Azure(WA)上部署它们。但是,我已经安装了WA SDK 1.7(6月7日),它与Eclipse和插件不兼容,所以我不得不使用commando。我决定在Eclipse中创建项目(具有Web角色和辅助角色)并尝试运行以下命令来重新创建cscfg文件和.csx文件夹,然后在计算模拟器上运行它...

 cspack ServiceDefinition.csdef /generateConfigurationFile:ServiceConfiguration.cscfg /copyonly

...但它会产生以下错误......

Error : CloudServices38 : The entrypoint dll is not defined for worker role MyPhpProj_MyWorkerRole.

感谢您的建议。

1 个答案:

答案 0 :(得分:8)

在Web和Worker角色中,您确实需要提供角色入口点或程序入口点。我知道在自定义工作者角色中没有辅助角色DLL,但是您可以将PHP.EXE或Java.exe或Nodejs.exe用作ProgramEntryPoint。

解决此问题的方法是将ProgramEntryPoint与Windows Azure辅助角色一起使用。我将举例说明如何使用它,以便您可以在Windows Azure PHP应用程序中使用:

因此,如果您的工作者角色名称为“TestWorker”,并且文件夹TestWorker包含您的PHP.EXE以及其他文件,您的应用程序文件夹如下所示:

enter image description here

现在您还可以编辑/添加ServiceDefinition.cscfg以包含正确的WorkerRole设置以及ProgramEntryPoint,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="WorkerRoleApp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-05.1.7">
 <WorkerRole name="TestWorker" vmsize="Small">
   <Runtime executionContext="limited">
     <EntryPoint>
      <ProgramEntryPoint commandLine="php.exe" setReadyOnProcessStart="true" />
     </EntryPoint>
   </Runtime>
   <Endpoints>
        <InputEndpoint name="PhpHttpIn" protocol="http" port="80" />
   </Endpoints>
  </WorkerRole>
</ServiceDefinition>

最后,您可以使用CSPACK命令构建您的Package,然后在Compute Emulator中本地测试它:

cspack ServiceDefinition.csdef /role:TestWorker;TestWorker /copyOnly 
   /out:WorkerRoleApp.csx /generateConfigurationFile:ServiceConfiguration.cscfg

最后结果如下所示:

enter image description here