启用 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 位密钥。
常见原因
- RSA 密钥长度:Windows 11 和 Windows Server 2022 不支持将 RSA 2048 位密钥用于 Azure Disk Encryption。
- 缺少依赖项:某些 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 中的包装问题。
- 修改加密设置:
- 打开 Azure 门户。
- 导航到您的 VM 并选择 Disks。
- 使用 BEK 而不是 KEK 配置磁盘加密。
- 测试加密:
- 启用磁盘加密后重启 VM。
- 验证加密已成功应用且没有错误。
解决方案 2:增加 RSA 密钥长度
Windows 11 和 Windows Server 2022 需要大于 2048 位的 RSA 密钥长度。请将您的 Key Vault 密钥更新为 RSA 3072 或 RSA 4096 以解决此问题。
- 创建新的 RSA 密钥:
- 在 Azure 门户中转到 Azure Key Vault
- 选择 Keys 并单击 Generate/Import。
- 选择 RSA-HSM ,密钥大小为 3072 或 4096 位。
- 更新磁盘加密设置:
- 在加密配置中使用新的 RSA 密钥。
- 重启 VM 以应用更改。
- 验证加密:
- 检查预配状态,确保磁盘加密扩展成功。
关键注意事项
对于其他 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 和密钥的实际名称。
参考资料
如需进一步排查和指导,请浏览以下资源: