【Azure 應用服務】App Service服務無法啟動,開啟Kudu站點,App Service Editor 頁面均丟擲:The service is unavailable

路邊兩盞燈 發表於 2021-07-26

問題描述

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.

【Azure 應用服務】App Service服務無法啟動,開啟Kudu站點,App Service Editor 頁面均丟擲:The service is unavailable

 

 異常訊息全文:

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 ,如下圖:

【Azure 應用服務】App Service服務無法啟動,開啟Kudu站點,App Service Editor 頁面均丟擲:The service is unavailable

  • 在下面的 Console 介面中輸入命令 du -sh * 檢視具體檔案佔用大小,如圖所示:

【Azure 應用服務】App Service服務無法啟動,開啟Kudu站點,App Service Editor 頁面均丟擲:The service is unavailable

 

 

參考資料

在 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