針對 Azure Windows VM 代理程式問題進行疑難解答

注意事項

本文是否有幫助? 您的輸入對我們很重要。 請使用此頁面上的 [ 意見反應 ] 按鈕,讓我們知道本文如何為您運作,或我們如何加以改善。

Azure VM 代理程式是虛擬機 (VM) 代理程式。 它可讓 VM 與網狀架構控制器通訊, (VM 裝載所在的基礎實體伺服器) IP 位址 168.63.129.16。 此位址是有助於通訊的虛擬公用IP位址。 如需詳細資訊,請 參閱什麼是IP位址168.63.129.16?

從內部部署環境移轉至 Azure 或使用自定義映像建立的 VM 未安裝 Azure VM 代理程式。 在這些案例中,您必須手動安裝 VM 代理程式。 如需如何安裝 VM 代理程式的詳細資訊,請參閱 Azure 虛擬機器代理程式概觀

成功安裝 Azure VM 代理程序之後,您可以在 VM 上的 services.msc 中看到下列服務。

Service 描述
Windows Azure 客體代理程式 此服務負責設定從客體 VM 到主機代理程式的各種擴充功能和通訊。 它也負責收集 WaAppAgent.log中的記錄。
遙測 此服務負責將 VM 的遙測數據傳送至後端伺服器。
RdAgent 此服務負責安裝客體代理程式。 (透明安裝程式是 RdAgent 的另一個元件,可協助升級客體代理程式的其他元件和服務。) RdAgent 也負責將活動訊號從客體 VM 傳送到實體伺服器上的主機代理程式。

注意事項

從客體代理程式 2.7.41491.971 版開始,遙測元件包含在 Windows Azure 客體代理程式服務中。 因此,您可能不會在新建立的 VM 中看到此遙測服務列出。

疑難解答檢查清單

若要讓任何 VM 擴充功能能夠執行,必須安裝 Azure VM 客體代理程式並順利運作。 如果您看到客體代理程序回報為 未就緒,或延伸模塊失敗並傳回錯誤訊息,例如 VMAgentStatusCommunicationError,請遵循下列步驟來開始針對客體代理程序進行疑難解答。

步驟 1:檢查 VM 是否已啟動

若要確認 VM 已啟動,請遵循下列步驟:

  1. Azure 入口網站 中,搜尋並選取 [虛擬機]

  2. 在 VM 清單中,選取 Azure VM 的名稱。

  3. 在 Azure VM 的瀏覽窗格中,選取 [ 概觀]

  4. 如果 VM 尚未開啟,請找出 [概 ] 頁面頂端的動作清單,然後選取 [ 開始 ] 連結。

此外,請確認作業系統 (操作系統) 已啟動並成功執行。

步驟 2:檢查客體代理程式是否就緒

當您仍在 Azure 入口網站 的 [VM 概觀] 頁面上時,請選取 [屬性] 索引標籤。如果 [代理程序狀態] 字段的值為 [就緒],請確認 [代理程式版本] 域值符合支援的最低版本。 下列螢幕快照顯示您可以在何處找到這些欄位。

Azure 入口網站 顯示虛擬機 (VM) 屬性的螢幕快照。代理程序狀態為 Ready,而 Agent 版本為 2.7.41491.1083。

如果客體代理程序狀態 為 [就緒 ],但您有涉及 VM 擴充功能的問題,請參閱 Azure 虛擬機擴充功能和功能 ,以檢閱疑難解答建議。

如果客體代理程序狀態 未就緒 或空白,則客體代理程式未安裝或無法正常運作。

步驟 3:檢查客體代理程式服務是否正在執行

  1. 使用遠端桌面通訊協定 (RDP) 連線到您的 VM

    注意事項

    客體代理程式不需要 RDP 連線即可順利運作。 如果您遇到會影響 VM RDP 連線的問題,請參閱 針對 Azure 虛擬機器的遠端桌面連線進行疑難解答

  2. 在您的 VM 上,選取 [ 開始],搜尋 services.msc,然後選取 [服務 ] 應用程式。

  3. 在 [ 服務] 視窗中,選取 [RdAgent ] 服務。

  4. 選取 [ 動作] 功能表,然後選取 [ 屬性]

  5. 在 [屬性] 對話框的 [一般] 索引標籤上,確定下列條件為 true,然後選取 [確定] 或 [取消] 按鈕:

    • [ 啟動類型 ] 下拉式清單設定為 [ 自動]
    • [ 服務狀態] 欄位的值為 [ 執行中]

    [RdAgent 屬性] 對話框的螢幕快照。對話框會將 RdAgent 服務狀態顯示為 [執行中],並將啟動類型顯示為 [自動]。

  6. 在 [ 服務] 視窗中,選取 [WindowsAzureGuestAgent ] 服務。

  7. 重複步驟 4 和 5。

如果服務不存在,則可能未安裝客體代理程式。 在此情況下,您可以 手動安裝客體代理程式。 執行手動安裝之前, 請先檢查安裝必要條件

步驟 4:測試 WireServer 連線能力

若要順利執行,客體代理程式需要連線到埠8032526上的WireServerIP (主機IP) 位址168.63.129.16。 如需如何測試此IP位址連線能力的指示,請參閱什麼是IP位址168.63.129.16疑難解答連線一節。

如果該區段中的任何測試未連線,請檢查可能導致下列任何元件封鎖IP位址 168.63.129.16存取的問題:

  • 防火牆
  • Proxy
  • 應用程式

步驟 5:檢閱記錄檔

檢查下列記錄檔位置是否有任何值得注意的錯誤:

  • C:\WindowsAzure\Logs\WaAppAgent.log
  • C:\WindowsAzure\Logs\TransparentInstaller.log

將您發現的任何錯誤與下列可能導致 Azure VM 代理程式顯示 未就緒 狀態或如預期停止運作的常見案例進行比較。

原因 1:使用 Azure VM 代理程式 2.7.41491.1004 版的 Windows VM 體驗問題,涉及 Sysprep

在這些 VM 上執行 Sysprep 可能會導致下列錯誤:

  • 當您第一次執行 Sysprep 時,您會看到下列錯誤訊息:

    系統管理員:錯誤處理程式

  • 當您執行 Sysprep 一次以上時,您會看到下列錯誤訊息:

    嘗試對 VM 進行 sysprep 處理時發生嚴重錯誤

解決方案 1:重設 VM 的 Sysprep 狀態,然後將 Azure VM 代理程式升級至更新版本

重要事項

這個章節、方法或工作包含修改登錄的步驟。 然而,不當修改登錄可能會發生嚴重的問題。 因此,請務必謹慎地依照這些步驟執行。 若要獲得保護,請在進行修改前先備份登錄,以便在出現問題時還原登錄。 如需進一步了解如何備份及還原登錄的相關資訊,請參閱如何在 Windows 中備份及還原登錄

首先,重設 VM 的 Sysprep 狀態。 重設涉及 修改某些登錄機碼。 然後,您可以將 Azure VM 代理程式升級至更新版本。 因為問題只發生在 2.7.41491.1004 版中,所以您可以嘗試將代理程序升級至最新的代理程式版本。

原因 2:代理程式卡在「開始」程式中

WaAppAgent.log 檔案中,您可以看到代理程式卡在「啟動」程式中,而且無法啟動:

[00000007] [05/28/2019 12:58:50.90] [INFO] WindowsAzureGuestAgent starting. Version 2.7.41491.901

VM 仍在執行舊版的 Azure VM 代理程式。 在 C:\WindowsAzure 資料夾中,您可能會注意到已安裝許多 Azure VM 代理程式實例,包括數個具有相同版本的實例。 因為已安裝多個代理程序實例,所以 VM 不會啟動最新版的 Azure VM 代理程式。

解決方案 2:手動卸載並重新安裝 Azure VM 代理程式

手動卸載 Azure VM 代理程式,然後依照下列步驟重新安裝:

  1. 啟 控制台>Programs and Features],然後卸載 Azure VM 代理程式。

  2. 啟動任務管理員,然後停止下列服務:

    • Azure VM 代理程序服務
    • RdAgent 服務
    • Windows Azure 遙測服務
    • Windows Azure 網路代理程序服務
  3. C:\WindowsAzure 下,建立名為 OLD 的文件夾。

  4. 將任何名為 PackagesGuestAgent 的資料夾移至 OLD 資料夾。 此外,將 C:\WindowsAzure\logs 中以 GuestAgent_x.x.xxxxx 開頭的任何 GuestAgent 資料夾移至 OLD 資料夾。

  5. 下載並安裝最新版的 Windows Installer (MSI) 代理程式。 您必須具有系統管理員許可權才能完成安裝。

  6. 執行下列 msiexec 命令來安裝客體代理程式:

    msiexec.exe /i c:\VMAgentMSI\WindowsAzureVmAgent.2.7.<version>.fre.msi /quiet /L*v c:\VMAgentMSI\msiexec.log
    
  7. 確認 RdAgent、Azure VM 代理程式和 Windows Azure 遙測服務現在正在執行。

  8. 檢查 WaAppAgent.log 檔案,以確定最新版的 Azure VM 代理程式正在執行。

  9. 刪除 C:\WindowsAzure 下的 OLD 資料夾。

原因 3:無法連線到 WireServer IP (主機 IP)

您會注意到WaAppAgent.log和Telemetry.log檔案中有下列錯誤專案:

[ERROR] GetVersions() failed with exception: Microsoft.ServiceModel.Web.WebProtocolException: Server Error: Service Unavailable (ServiceUnavailable) ---> 
System.Net.WebException: The remote server returned an error: (503) Server Unavailable.
[00000011] [12/11/2018 06:27:55.66] [WARN]  (Ignoring) Exception while fetching supported versions from HostGAPlugin: System.Net.WebException: Unable to connect to the remote server 
---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 168.63.129.16:32526
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState status, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadString(Uri address)
at Microsoft.GuestAgentHostPlugin.Client.GuestInformationServiceClient.GetVersions()
at Microsoft.WindowsAzure.GuestAgent.ContainerStateMachine.HostGAPluginUtility.UpdateHostGAPluginAvailability()`

這些錯誤專案表示 VM 無法連線到 WireServer 主機伺服器。

解決方案 3:啟用 DHCP,並確定伺服器未遭到防火牆、Proxy 或其他來源封鎖

  1. 由於無法連線 WireServer,請使用遠端桌面連線到 VM,然後嘗試在網頁瀏覽器中存取 URL http://168.63.129.16/?comp=versions

  2. 如果您無法連線到步驟 1 中的 URL,請檢查網路介面,以判斷是否已啟用該介面以使用動態主機設定通訊協定 (DHCP) 並具有 DNS。 若要檢查網路介面的 DHCP 狀態,請執行下列 網路殼 層 (netsh) 介面 IP 命令來 顯示組態

    netsh interface ip show config
    
  3. 如果停用 DHCP,請針對設定位址執行下列netsh介面 IP 命令:

    netsh interface ip set address name="<name-of-the-interface>" source=dhcp
    

    注意: 在此命令中,將佔位元值變更為介面的名稱。

  4. 檢查防火牆、Proxy 或其他來源可能造成封鎖 IP 位址存取的任何問題。 168.63.129.16

  5. 檢查 Windows 防火牆或第三方防火牆是否封鎖對埠 80 和 的存 32526取。 如需為何不應封鎖此位址的詳細資訊,請參閱 什麼是IP位址168.63.129.16?

原因 4:客體代理程式卡在「停止」程式中

您會注意到 WaAppAgent.log 檔案中有下列錯誤專案:

[00000007] [07/18/2019 14:46:28.87] [WARN] WindowsAzureGuestAgent stopping.
[00000007] [07/18/2019 14:46:28.89] [INFO] Uninitializing StateExecutor with WaitForTerminalStateReachedOnEnd : True
[00000004] [07/18/2019 14:46:28.89] [WARN] WindowsAzureGuestAgent could not be stopped. Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.WindowsAzure.GuestAgent.ContainerStateMachine.GoalStateExecutorBase.WaitForExtensionWorkflowComplete(Boolean WaitForTerminalStateReachedOnEnd)
at Microsoft.WindowsAzure.GuestAgent.ContainerStateMachine.GoalStateExecutorBase.Uninitialize(Boolean WaitForTerminalStateReachedOnEnd)
at Microsoft.WindowsAzure.GuestAgent.ContainerStateMachine.GoalStateExecutorForCloud.Uninitialize(Boolean WaitForTerminalStateReachedOnEnd)
at Microsoft.WindowsAzure.GuestAgent.AgentCore.AgentCore.Stop(Boolean waitForTerminalState)
at Microsoft.WindowsAzure.GuestAgent.AgentCore.AgentService.DoStopService()
at Microsoft.WindowsAzure.GuestAgent.AgentCore.AgentService.<>c__DisplayClass2.<OnStopProcessing>b__1()

這些錯誤專案表示 Azure VM 代理程式卡在「停止」程式中。

解決方案 4a:啟動 WaAppAgent.exe 並停止 WindowsAzureGuest.exe

請確定 WaAppAgent.exe 在 VM 上執行。 如果未執行,請重新啟動 RdAgent 服務,然後等候五分鐘。 WaAppAgent.exe 開始執行之後,結束 WindowsAzureGuest.exe 程式。

解決方案 4b:升級至最新版的 Azure VM 代理程式

如果解決方案 4a 無法解決問題,請移除目前安裝的版本,然後手動安裝最新版的代理程式。

原因 5:已安裝致使的回送配接器

您會注意到 WaAppAgent.log 檔案中有下列錯誤專案:

[00000006] [06/20/2019 07:44:28.93] [INFO]  Attempting to discover fabric address on interface Npcap Loopback Adapter.
[00000024] [06/20/2019 07:44:28.93] [WARN]  Empty DHCP option data returned
[00000006] [06/20/2019 07:44:28.93] [ERROR] Did not discover fabric address on interface Npcap Loopback Adapter

這些錯誤專案表示 Wireshark已 將封包擷取安裝 (VM 上網路對應程式 (Nmap) Project 的) 回送適配卡。 Wireshark 是一種開放原始碼工具,可用來分析網路流量和分析封包。 這類工具通常稱為網路分析器、網路協定分析器或探查程式。

解決方案5:停用回送功能配接器

請嘗試停用與之連線的回送配接器,然後檢查問題是否已解決。

原因 6:遠端過程調用 (RPC) 問題

您會注意到 WaAppAgent.log 檔案中有下列錯誤專案:

[00000004] [01/12/2019 00:30:47.24] [ERROR] RdCrypt Initialization failed. Error Code: -2147023143.
[00000004] [01/12/2019 00:30:47.24] [ERROR] Failed to get TransportCertificate. Error: System.AccessViolationException
Microsoft.Cis.Fabric.CertificateServices.RdCertificateFactory.Shutdown()
[00000004] [01/12/2019 00:30:47.24] [WARN]  Could not get transport certificate from agent runtime for subject name: 12345678-d7c8-4387-8cf3-d7ecf62544e5. Installing certificates in the LocalMachine store failed.
[00000004] [01/12/2019 00:30:47.24] [WARN] Fetching certificate blob from the cert URI: http://168.63.129.16/machine/12345678-d7c8-4387-8cf3-d7ecf62544e5/12345678-d447-4b10-a5da-1ba1581cd7d7._VMName?comp=certificates&incarnation=2 failed with exception: System.NullReferenceException
-2147023143 = 0x6d9 = EPT_S_NOT_REGISTERED

這些錯誤專案可能是由遠端過程調用 (RPC) 問題所造成。 例如,RPC 端點可能未接聽,或相反端的 RPC 進程可能遺失。

解決方案 6:啟動 CNG 金鑰隔離服務

執行下列 portqry 命令 (,檢查) Windows 服務) 金鑰隔離 (CNGKEYISO CNG 的新一代密碼編譯是否在 RPC 端點清單中:

portqry -n <VMName> -e 135

如果您沒有看到 CNGKEYISO 此程式,請從 Windows 服務控制台啟動它, (CNG 金鑰隔離 = KeyIso) ,然後重新啟動 WaAppAgent.exeWindowsAzureGuestAgent.exe

原因 7:PInvoke PFXImportCertStore 失敗,並傳回 Null 句柄。 錯誤碼:86

Windows 客體代理程式正在執行,但擴充功能無法運作。 您會注意到 WaAppAgent.log 檔案中有下列錯誤專案:

PInvoke PFXImportCertStore failed and null handle is returned. Error Code: 86

[00000003] [10/21/2020 02:37:45.98] [WARN]  Could not get transport certificate from agent runtime for subject name: 12345678-dae3-4c2f-be57-55c0ab7a44e5. Installing certificates in the LocalMachine store failed.
[00000003] [10/21/2020 02:37:45.98] [ERROR] Installing certificates in the LocalMachine store failed with exception: Microsoft.WindowsAzure.GuestAgent.CertificateManager.CryptographyNative+PInvokeException: PInvoke PFXImportCertStore failed and null handle is returned. Error Code: 86.

這些錯誤專案可能是因為 SYSTEM 帳戶的 Crypto 資料夾缺少許可權所造成。 如果您在 RdAgent 或 WindowsAzureGuestAgent) (重新啟動客體代理程式服務時收集行程 監視 (ProcMon) 追蹤,您應該會看到一些「拒絕存取」錯誤。

解決方案 7:將 Crypto 資料夾的完整控制權新增至 SYSTEM 帳戶

請確定 SYSTEM 帳戶具有下列資料夾的 完全控制權 限:

  • C:\ProgramData\Microsoft\Crypto\Keys

  • C:\ProgramData\Microsoft\Crypto\RSA

  • C:\ProgramData\Microsoft\Crypto\SystemKeys

原因 8:System.BadImageFormatException:嘗試載入格式不正確的程式。 (來自 HRESULT 的例外狀況:0x8007000B)

您會注意到 WaAppAgent.log 檔案中有下列錯誤專案,指出客體代理程式沒有回應:

[00000018] 2021-01-12T16:35:45Z [INFO]  Test extract the plugin zip file to the temp folder C:\TEMP\12345678-5f85-45dc-9f17-55be1fde7b10
[00000010] 2021-01-12T16:35:45Z [ERROR] InstallPlugins() failed with exception: System.AggregateException: One or more errors occurred. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at Microsoft.WindowsAzure.GuestAgent.ExtensionStateMachine.PluginInstaller.PackageExpand(String packageFilePath, String destinationPath)
   at Microsoft.WindowsAzure.GuestAgent.ExtensionStateMachine.PluginInstaller.ValidateExtensionZipFile(String pluginName, String pluginVersion, String& pluginZipFile)

這些錯誤專案很可能是因為第三方應用程式已安裝在 VM 上,且已修改 32 位或 64 位 .NET 應用程式的行為。

BadImageFormatException當 64 位應用程式正在載入 32 位 DLL 時,就會發生錯誤。

解決方案 8:設定 .NET Framework 的 Enable64Bit 登錄專案,然後重新啟動 VM

重要事項

這個章節、方法或工作包含修改登錄的步驟。 然而,不當修改登錄可能會發生嚴重的問題。 因此,請務必謹慎地依照這些步驟執行。 若要獲得保護,請在進行修改前先備份登錄,以便在出現問題時還原登錄。 如需進一步了解如何備份及還原登錄的相關資訊,請參閱如何在 Windows 中備份及還原登錄

開啟登錄,找出 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework 登錄子機碼,然後檢視 Enable64Bit 登錄專案。

如果 Enable64Bit 登錄專案設定為 0,則 64 位 .NET 應用程式會被視為 32 位應用程式。 因此,Azure VM 代理程式無法運作。

解決方案是將 Enable64Bit 金鑰設定為 1,然後重新啟動 VM。

原因 9:Windows 客體代理程序因為 ConfigurationErrorsException 或 TypeInitializationException 錯誤而無法啟動

Windows 客體代理程式在啟動時停止回應,並顯示下列應用程式記錄專案:

Log Name:      Application
Source:        .NET Runtime
Date:          3/07/2023 10:25:59 AM
Event ID:      1026
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      vm372437823
Description:
Application: WindowsAzureGuestAgent.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Configuration.ConfigurationErrorsException
   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean)
   at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(System.Configuration.ConfigurationSchemaErrors)
   at System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)

Exception Info: System.Configuration.ConfigurationErrorsException
   at System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)
   at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String)
   at System.Configuration.ConfigurationManager.GetSection(System.String)
   at System.Configuration.PrivilegedConfigurationManager.GetSection(System.String)
   at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
   at System.Diagnostics.DiagnosticsConfiguration.Initialize()
   at System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()
   at System.Diagnostics.TraceInternal.InitializeSettings()
   at System.Diagnostics.Trace.set_AutoFlush(Boolean)
   at Microsoft.WindowsAzure.GuestAgent.Prime.TraceManager..cctor()

Exception Info: System.TypeInitializationException
   at Microsoft.WindowsAzure.GuestAgent.Prime.TraceManager.Write(System.String, System.Object[])
   at Microsoft.WindowsAzure.GuestAgent.AgentCore.AgentCore.Start()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()

如果 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config 檔案遺失或損毀,就可能發生此問題。

解決方案 9:將工作 machine.config 檔案複製到 VM,然後重新啟動客體代理程式服務

若要解決此問題,請執行下列步驟:

  1. 從工作 VM 複製 machine.config 檔案,然後將檔案貼到有問題 VM 上的 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config 資料夾。

  2. 執行和 net start 命令來net stop重新啟動客體代理程式服務:

    net stop RdAgent
    net stop WindowsAzureGuestAgent
    
    net start RdAgent
    net start WindowsAzureGuestAgent
    

後續步驟

其他與 Azure VM 代理程式相關聯的已知問題會列在其 GitHub 存放庫中

協力廠商資訊免責聲明

本文提及的協力廠商產品是由與 Microsoft 無關的獨立廠商所製造。 Microsoft 不以默示或其他方式,提供與這些產品的效能或可靠性有關的擔保。

協力廠商連絡資訊免責聲明

Microsoft 提供第三方連絡資訊,協助您尋找有關本主題的其他資訊。 此連絡資訊如有變更,恕不另行通知。 Microsoft 不保證第三方聯繫人信息的正確性。

與我們連絡,以取得說明

如果您有問題或需要相關協助,請建立支援要求,或詢問 Azure community 支援。 您也可以將產品意見反應提交給 Azure 意應見反社群