問題描述
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