问题描述
App Service 服务URL无法访问,进入门户中的Advanced Tools(Kudu)、App Service Editor (Preview)等页面无法打开, 打开就出现 The service is unavailable 错误。
问题排查和解决
由于无法打开高级工具(Kudu)并收集当前应用的日志,而根据错误消息“The service is unavailable”表明后端Host当前App Service的虚拟机实例出现了问题,那么可以通过人为的操作来改变后端实例。根据App Service不同定价层所使用的VM大小不一样,及多实例的设计原理,可以通过以下两种方式来改变后端实例:
1)增加定价层,把当前的实例级别提升(在 Azure 应用服务中纵向扩展应用:https://docs.azure.cn/zh-cn/app-service/manage-scale-up#scale-up-your-pricing-tier)
2)增加,减少实例个数(增加用于运行应用的 VM 实例数。 可以根据定价层,最多向外缩放到 30 个实例)
通过以上操作后,进入Kudu站点,查看 Logfiles 中日志,最终收集到App Service的日志,在日志中发现异常关键信息: There is not enough space on the disk.
异常消息全文:
System.Exception: Per site php.ini file was not created. ---> System.IO.IOException: There is not enough space on the disk.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost) at Microsoft.Web.Hosting.ProcessModel.SiteStartAndChangeManager.CreatePerSitePhpSettingsFile(StartSiteContext startSiteContext, String phpIniConfigPath, String phpInstallationPath, Version phpVersion) --- End of inner exception stack trace --- at Microsoft.Web.Hosting.ProcessModel.SiteStartAndChangeManager.CreatePerSitePhpSettingsFile(StartSiteContext startSiteContext, String phpIniConfigPath, String phpInstallationPath, Version phpVersion) at Microsoft.Web.Hosting.ProcessModel.SiteStartAndChangeManager.SetupPhpCallback(StartSiteContext startSiteContext, ICollection`1 configurationFiles, Version version, Boolean is64bit, String installationPath) at Microsoft.Web.Hosting.ProcessModel.SiteStartAndChangeManager.<>c__DisplayClass16_0.<CreateWorkItem>b__0(Version version, Boolean is64bit, String path) at Microsoft.Web.Hosting.StartSiteContext.SetupPhp(Func`4 versionCallback) at Microsoft.Web.Hosting.ProcessModel.SiteStartAndChangeManager.CreateWorkItem(StartSiteContext startSiteContext, DateTime requestTimestamp, ServiceContextMode mode, PerfData coldStartPerfData, String coldStartRequestId, Boolean handlingChangeNotification, Boolean isPrewarmPing, GetZipFromFileCacheTask getZipTask) at Microsoft.Web.Hosting.ProcessModel.SiteStartAndChangeManager.ProvisionSiteInNormalMode(DateTime startTime, StartSiteContext startSiteContext, PerfData coldStartPerfData, String appHostPath, String requestId, Boolean isRequestFromExternalSource, Boolean isPrewarmPing) at Microsoft.Web.Hosting.ProcessModel.SiteStartAndChangeManager.StartHostNameInternal(String hostName, Int32 serverPort, String token, String requestId, Boolean isHttpForward, Boolean isPrewarmPing) at Microsoft.Web.Hosting.ProcessModel.SiteStartAndChangeManager.StartHostName(String hostName, Int32 serverPort, String token, String requestId, Boolean isHttpForward, Boolean isPrewarmPing) |
#查看占用完空间的根源
- 进入Kudu -> Debug Console,然后选择
cmd
,如下图:
- 在下面的 Console 界面中输入命令
du -sh *
查看具体文件占用大小,如图所示:
参考资料
在 Azure 应用服务中纵向扩展应用:https://docs.azure.cn/zh-cn/app-service/manage-scale-up#scale-up-your-pricing-tier
如何检测 Web 应用沙盒环境文件系统存储量: https://docs.azure.cn/zh-cn/articles/azure-operations-guide/app-service-web/aog-app-service-web-howto-detect-file-storage-in-sandbox-environment