对无法启动的云服务角色进行故障排除Troubleshoot Cloud Service roles that fail to start

以下是一些与无法启动的 Azure 云服务角色相关的常见问题和解决方案。Here are some common problems and solutions related to Azure Cloud Services roles that fail to start.

如果本文未解决你的 Azure 问题,请访问 MSDN 和 CSDN 上的 Azure 论坛。If your Azure issue is not addressed in this article, visit the Azure forums on MSDN and CSDN. 可以在这些论坛上发布问题。You can post your issue in these forums. 还可提交 Azure 支持请求。You also can submit an Azure support request. 若要提交支持请求,请在 Azure 支持页上提交。To submit a support request, on the Azure support page.

缺少 DLL 或依赖项Missing DLLs or dependencies

DLL 或程序集缺失可能导致出现不响应的角色以及在“正在初始化”、“忙”和“正在停止”状态之间循环的角色。Unresponsive roles and roles that are cycling between Initializing, Busy, and Stopping states can be caused by missing DLLs or assemblies.

DLL 或程序集缺失的症状可能为:Symptoms of missing DLLs or assemblies can be:

  • 角色实例的状态在“正在初始化”、“忙”、“正在停止”之间循环。Your role instance is cycling through Initializing, Busy, and Stopping states.
  • 角色实例已转为“就绪” 状态,但导航到 Web 应用程序后未显示相应页面。Your role instance has moved to Ready but if you navigate to your web application, the page does not appear.

若要调查这些问题,可采用几种推荐的方法。There are several recommended methods for investigating these issues.

在 Web 角色中诊断缺失 DLL 的问题Diagnose missing DLL issues in a web role

如果导航到 Web 角色中部署的网站,且浏览器显示类似于下面的服务器错误,可能指示 DLL 缺失。When you navigate to a website that is deployed in a web role, and the browser displays a server error similar to the following, it may indicate that a DLL is missing.

'/' 应用程序中出现服务器错误。

通过关闭自定义错误来诊断问题Diagnose issues by turning off custom errors

可通过配置 Web 角色的 web.config,将自定义错误模式设置为“关闭”并重新部署服务,来查看更完整的错误信息。More complete error information can be viewed by configuring the web.config for the web role to set the custom error mode to Off and redeploying the service.

若要在不使用远程桌面的情况下查看更完整的错误,请执行以下操作:To view more complete errors without using Remote Desktop:

  1. 在 Microsoft Visual Studio 中打开解决方案。Open the solution in Microsoft Visual Studio.

  2. 在“解决方案资源管理器”中,找到 web.config 文件并打开。In the Solution Explorer, locate the web.config file and open it.

  3. 在 web.config 文件中,找到 system.web 部分并添加以下行:In the web.config file, locate the system.web section and add the following line:

    <customErrors mode="Off" />
    
  4. 保存文件。Save the file.

  5. 重新打包并重新部署服务。Repackage and redeploy the service.

重新部署服务后,会看到错误消息,其中包含缺失的程序集或 DLL 的名称。Once the service is redeployed, you will see an error message with the name of the missing assembly or DLL.

通过远程查看错误来诊断问题Diagnose issues by viewing the error remotely

可使用远程桌面来访问角色并远程查看更完整的错误信息。You can use Remote Desktop to access the role and view more complete error information remotely. 通过以下步骤使用远程桌面来查看错误:Use the following steps to view the errors by using Remote Desktop:

  1. 确保安装了 Azure SDK 1.3 或更高版本。Ensure that Azure SDK 1.3 or later is installed.

  2. 在使用 Visual Studio 部署解决方案的过程中,启用远程桌面。During the deployment of the solution by using Visual Studio, enable Remote Desktop. 有关详细信息,请参阅使用 Visual Studio 为 Azure 云服务中的角色启用远程桌面连接For more information, see Enable Remote Desktop Connection for a Role in Azure Cloud Services using Visual Studio.

  3. 在 Azure 门户中,在实例显示“就绪”状态后,远程连接到该实例。In the Azure portal, once the instance shows a status of Ready, remote into the instance. 有关通过云服务使用远程桌面的详细信息,请参阅远程连接到角色实例For more information on using the remote desktop with Cloud Services, see Remote into role instances.

  4. 使用在远程桌面配置期间指定的凭据登录到虚拟机。Sign in to the virtual machine by using the credentials that were specified during the Remote Desktop configuration.

  5. 打开命令窗口。Open a command window.

  6. 键入 IPconfigType IPconfig.

  7. 记录 IPV4 地址值。Note the IPV4 Address value.

  8. 打开 Internet Explorer。Open Internet Explorer.

  9. 键入 Web 应用程序的地址和名称。Type the address and the name of the web application. 例如, http://<IPV4 Address>/default.aspxFor example, http://<IPV4 Address>/default.aspx.

现在,导航到网站返回更明确的错误消息:Navigating to the website will now return more explicit error messages:

  • '/' 应用程序中出现服务器错误。Server Error in '/' Application.

  • 说明:执行当前 Web 请求期间,出现未处理的异常。Description: An unhandled exception occurred during the execution of the current web request. 请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。Please review the stack trace for more information about the error and where it originated in the code.

  • 异常详细信息:System.IO.FIleNotFoundException:未能加载文件或程序集“Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf856ad364e35”或它的某一个依赖项。Exception Details: System.IO.FIleNotFoundException: Could not load file or assembly ‘Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf856ad364e35’ or one of its dependencies. 系统找不到指定的文件。The system cannot find the file specified.

例如:For example:

'/' 应用程序中出现显式服务器错误

使用计算模拟器诊断问题Diagnose issues by using the compute emulator

可以使用 Azure 计算模拟器来诊断并解决缺失依赖项和出现 web.config 错误的问题。You can use the Azure compute emulator to diagnose and troubleshoot issues of missing dependencies and web.config errors.

为了在使用此诊断方法时获得最佳结果,应使用包含 Windows 的干净安装的计算机或虚拟机。For best results in using this method of diagnosis, you should use a computer or virtual machine that has a clean installation of Windows. 若要以最佳效果模拟 Azure 环境,请使用 Windows Server 2008 R2 x64。To best simulate the Azure environment, use Windows Server 2008 R2 x64.

  1. 安装独立版本的 Azure SDKInstall the standalone version of the Azure SDK

  2. 在开发计算机上生成云服务项目。On the development machine, build the cloud service project.

  3. 在 Windows 资源管理器中,导航到云服务项目的 bin\debug 文件夹。In Windows Explorer, navigate to the bin\debug folder of the cloud service project.

  4. 将 .csx 文件夹和 .cscfg 文件复制到用于调试问题的计算机。Copy the .csx folder and .cscfg file to the computer that you are using to debug the issues.

  5. 在干净的计算机上打开 Azure SDK 命令提示符窗口并键入 csrun.exe /devstore:startOn the clean machine, open an Azure SDK Command Prompt window and type csrun.exe /devstore:start.

  6. 在命令提示符处,键入 run csrun <path to .csx folder> <path to .cscfg file> /launchBrowserAt the command prompt, type run csrun <path to .csx folder> <path to .cscfg file> /launchBrowser.

  7. 角色启动后,会在 Internet Explorer 中看到详细的错误信息。When the role starts, you will see detailed error information in Internet Explorer. 还可使用标准的 Windows 故障排除工具来进一步诊断问题。You can also use standard Windows troubleshooting tools to further diagnose the problem.

使用 IntelliTrace 诊断问题Diagnose issues by using IntelliTrace

对于使用 .NET Framework 4 的辅助角色和 Web 角色,可以使用 Microsoft Visual Studio Enterprise 中提供的 IntelliTraceFor worker and web roles that use .NET Framework 4, you can use IntelliTrace, which is available in Microsoft Visual Studio Enterprise.

请按照以下步骤操作来部署启用了 IntelliTrace 的服务:Follow these steps to deploy the service with IntelliTrace enabled:

  1. 确认已安装 Azure SDK 1.3 或更高版本。Confirm that Azure SDK 1.3 or later is installed.

  2. 使用 Visual Studio 部署解决方案。Deploy the solution by using Visual Studio. 在部署期间,请选中“为 .NET 4 角色启用 IntelliTrace” 复选框。During deployment, check the Enable IntelliTrace for .NET 4 roles check box.

  3. 实例启动后,打开“服务器资源管理器” 。Once the instance starts, open the Server Explorer.

  4. 展开“Azure\Cloud Services”节点并查找部署。Expand the Azure\Cloud Services node and locate the deployment.

  5. 展开部署,直至看到角色实例。Expand the deployment until you see the role instances. 右键单击其中一个实例。Right-click on one of the instances.

  6. 选择“查看 IntelliTrace 日志” 。Choose View IntelliTrace logs. 此时会打开“IntelliTrace 摘要” 。The IntelliTrace Summary will open.

  7. 查找摘要的异常部分。Locate the exceptions section of the summary. 如果存在异常,则会将该部分标记为“异常数据” 。If there are exceptions, the section will be labeled Exception Data.

  8. 展开“异常数据”并查找类似如下内容的 System.IO.FileNotFoundException 错误:Expand the Exception Data and look for System.IO.FileNotFoundException errors similar to the following:

异常数据、缺少文件或程序集

解决缺失 DLL 和程序集的问题Address missing DLLs and assemblies

若要纠正丢失 DLL 和程序集错误,请按照以下步骤进行操作:To address missing DLL and assembly errors, follow these steps:

  1. 在 Visual Studio 中打开解决方案。Open the solution in Visual Studio.

  2. 在“解决方案资源管理器”中,打开 References 文件夹。In Solution Explorer, open the References folder.

  3. 单击错误中标识的程序集。Click the assembly identified in the error.

  4. 在“属性”窗格中,找到“复制本地属性”并将值设置为“True”。In the Properties pane, locate Copy Local property and set the value to True.

  5. 重新部署云服务。Redeploy the cloud service.

确认所有错误均已更正后,可以在不选中“为 .NET 4 角色启用 IntelliTrace” 复选框的情况下部署服务。Once you have verified that all errors have been corrected, you can deploy the service without checking the Enable IntelliTrace for .NET 4 roles check box.