疑難排解 Azure Disk Encryption 錯誤:RUNTIME_E_KEYVAULT_SECRET_WRAP_WITH_KEK_FAILED

啟用 Azure Disk Encryption 為您的虛擬機器 (VM) 啟用時,您可能會遇到以下錯誤:

JSON'code': 'VMExtensionProvisioningError',
'message': 'VM has reported a failure when processing extension 'AzureDiskEncryption' (publisher 'Microsoft.Azure.Security' and type 'AzureDiskEncryption'). Error message: '[2.5.0.3] Failed to enable Azure Disk Encryption on the VM with the following exception details:\n Microsoft.Cis.Security.BitLocker.BitlockerIaasVMExtension.BitlockerFailedToSendEncryptionSettingsException: The fault reason was: '0xc142506f  RUNTIME_E_KEYVAULT_SECRET_WRAP_WITH_KEK_FAILED  Key vault secret wrap with key encryption key failed.'.\r\n   at Microsoft.Cis.Security.BitLocker.BitlockerIaasVMExtension.WireProtocol.WireProtocolMessage.SendEncryptionSettingsToHost() in C:\\__w\\1\\s\\src\\BitLocker\\BitlockerIaasVMExtension\\WireProtocol\\WireProtocolMessage.cs:line 210\r\n   at Microsoft.Cis.Security.BitLocker.BitlockerIaasVMExtension.BitlockerExtension.SendEncryptionSettingsToHostV3(VmEncryptionSettings vmSettings) in C:\\__w\\1\\s\\src\\BitLocker\\BitlockerIaasVMExtension\\BitlockerExtension.cs:line 1092'. More information on troubleshooting is available at https://aka.ms/VMExtensionADEWindowsTroubleshoot.'

錯誤分析

錯誤訊息表明,問題源於例外狀況 RUNTIME_E_KEYVAULT_SECRET_WRAP_WITH_KEK_FAILED。這表示 Key Vault 在使用下列工具包裝加密金鑰的操作中失敗: 金鑰加密金鑰 (KEK)。

需要注意的是,所使用的 VM 作業系統是 Windows 11 Pro,已知它與 Azure Disk Encryption 存在相容性問題,原因是缺乏對 RSA 2048 位元金鑰。

常見原因

  1. RSA 金鑰長度:Windows 11 和 Windows Server 2022 不支援將 RSA 2048 位元金鑰用於 Azure Disk Encryption。
  2. 缺少相依性:某些 Windows Server 設定需要其他元件,例如 bdehdcfg 或 .NET Framework。

官方文件

Microsoft 已在文章 為 Windows VM 啟用 Azure Disk Encryption 中承認了這一限制,並提供了一個常見問題解答部分,建議對某些 OS 版本使用更長的 RSA 金鑰長度。


要解決此錯誤並成功啟用 Azure Disk Encryption,請遵循下面詳細介紹的兩種方法之一:

解決方案 1:使用 BitLocker 加密金鑰 (BEK)

Azure Disk Encryption 支援使用下列方式加密: BitLocker 加密金鑰 (BEK)。使用 BEK 而不是金鑰加密金鑰 (KEK) 可以繞過 Key Vault 中的包裝問題。

  1. 修改加密設定:
    • 開啟 Azure 入口網站。
    • 瀏覽至您的 VM 並選取 Disks。
    • 使用 BEK 而不是 KEK 設定磁碟加密。
  2. 測試加密:
    • 啟用磁碟加密後重新啟動 VM。
    • 驗證加密已成功套用且沒有錯誤。

解決方案 2:增加 RSA 金鑰長度

Windows 11 和 Windows Server 2022 需要大於 2048 位元的 RSA 金鑰長度。請將您的 Key Vault 金鑰更新為 RSA 3072 或 RSA 4096 以解決此問題。

  1. 建立新的 RSA 金鑰:
    • 在 Azure 入口網站中前往 Azure Key Vault 
    • 選取 Keys 並按一下 Generate/Import。
    • 選取 RSA-HSM ,金鑰大小為 3072 或 4096 位元。
  2. 更新磁碟加密設定:
    • 在加密設定中使用新的 RSA 金鑰。
    • 重新啟動 VM 以套用變更。
  3. 驗證加密:
    • 檢查佈建狀態,確保磁碟加密擴充功能成功。

重要注意事項

對於其他 Windows Server 版本,請確保安裝了以下相依性:

作業系統需求
Windows Server 2012 R2 Core安裝 bdehdcfg 元件。
Windows Server 2016 Core安裝 bdehdcfg 元件。
Windows Server 2008 R2 .NET Framework 4.5 透過 Windows Update (KB2901983) 安裝。

請參閱有關 Azure Disk Encryption 必要條件的文件。


範例程式碼片段

以下是更新 Key Vault 的 RSA 金鑰長度的 Azure CLI 範例:

BASH# Create a new RSA key with 4096 bits in Azure Key Vault
az keyvault key create \
  --vault-name <YourKeyVaultName> \
  --name <YourKeyName> \
  --kty RSA \
  --size 4096

請確保將 <YourKeyVaultName> 和 <YourKeyName> 取代為您的 Key Vault 和金鑰的實際名稱。


參考資料

如需進一步疑難排解和指導,請瀏覽以下資源:

發表留言