本部分分步介绍如何使用 Azure 门户在现有 Azure 第 2 代 VM 上启用受信任启动。
- 登录到 Azure 门户
- 验证虚拟机生成是否为 V2,并停止 VM。
- 在“概述”页上 VM 的“属性”中,选择“安全类型”下的“标准”。 这会导航到 VM 的“配置”页。
- 在“配置”页的“安全类型”部分下,选择“安全类型”下拉列表。
- 选择下拉列表下的“受信任启动”,选中复选框以启用“安全启动”和“vTPM”。 进行所需的更改后,单击“保存”。
- 成功完成更新后,关闭“配置”页,并在“概述”页上 VM 的“属性”下验证“安全类型”。
- 启动已升级的受信任启动 VM,确保它已成功启动,并验证是否能够使用 RDP(对于 Windows VM)或 SSH(对于 Linux VM)登录 VM。
本部分分步介绍如何使用 Azure CLI 在现有 Azure 第 2 代 VM 上启用受信任启动。
确保已安装最新的 Azure CLI,并且已使用 az login 登录到 Azure 帐户。
- 登录 Azure 订阅
az cloud set -n AzureChinaCloud
az login
az account set --subscription 00000000-0000-0000-0000-000000000000
- 解除分配 VM
az vm deallocate \
--resource-group myResourceGroup --name myVm
- 通过将
--security-type
设置为 TrustedLaunch
启用受信任启动。
az vm update \
--resource-group myResourceGroup --name myVm \
--security-type TrustedLaunch \
--enable-secure-boot true --enable-vtpm true
- 验证上一个命令的输出。
securityProfile
配置随命令输出一起返回。
{
"securityProfile": {
"securityType": "TrustedLaunch",
"uefiSettings": {
"secureBootEnabled": true,
"vTpmEnabled": true
}
}
}
- 启动 VM。
az vm start \
--resource-group myResourceGroup --name myVm
- 启动已升级的受信任启动 VM,确保它已成功启动,并验证是否能够使用 RDP(对于 Windows VM)或 SSH(对于 Linux VM)登录 VM。
本部分分步介绍如何使用 Azure PowerShell 在现有 Azure 第 2 代 VM 上启用受信任启动。
确保已安装最新的 Azure PowerShell,并且已使用 Connect-AzAccount 登录到 Azure 帐户。
- 登录 Azure 订阅
Connect-AzAccount -Environment AzureChinaCloud -SubscriptionId 00000000-0000-0000-0000-000000000000
- 解除分配 VM
Stop-AzVM -ResourceGroupName myResourceGroup -Name myVm
- 通过将
--security-type
设置为 TrustedLaunch
启用受信任启动。
Get-AzVM -ResourceGroupName myResourceGroup -VMName myVm `
| Update-AzVM -SecurityType TrustedLaunch `
-EnableSecureBoot $true -EnableVtpm $true
- 在更新的 VM 配置中验证
securityProfile
。
# Following command output should be `TrustedLaunch`
(Get-AzVM -ResourceGroupName myResourceGroup -VMName myVm `
| Select-Object -Property SecurityProfile `
-ExpandProperty SecurityProfile).SecurityProfile.SecurityType
# Following command output should return `SecureBoot` and `vTPM` settings
(Get-AzVM -ResourceGroupName myResourceGroup -VMName myVm `
| Select-Object -Property SecurityProfile `
-ExpandProperty SecurityProfile).SecurityProfile.Uefisettings
- 启动 VM。
Start-AzVM -ResourceGroupName myResourceGroup -Name myVm
- 启动已升级的受信任启动 VM,确保它已成功启动,并验证是否能够使用 RDP(对于 Windows VM)或 SSH(对于 Linux VM)登录 VM。
本部分分步介绍如何使用 ARM 模板在现有 Azure 第 2 代 VM 上启用受信任启动。
资源管理器模板是定义项目基础结构和配置的 JavaScript 对象表示法 (JSON) 文件。 模板使用声明性语法。 在声明性语法中,你可以在不编写创建部署的编程命令序列的情况下,描述预期部署。
- 查看模板。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmsToUpgrade": {
"type": "object",
"metadata": {
"description": "Specifies the list of Gen2 virtual machines to be upgraded to Trusted launch."
}
},
"vTpmEnabled": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "Specifies whether vTPM should be enabled on the virtual machine."
}
}
},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2022-11-01",
"name": "[parameters('vmsToUpgrade').virtualMachines[copyIndex()].vmName]",
"location": "[parameters('vmsToUpgrade').virtualMachines[copyIndex()].location]",
"properties": {
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": "[parameters('vmsToUpgrade').virtualMachines[copyIndex()].secureBootEnabled]",
"vTpmEnabled": "[parameters('vTpmEnabled')]"
},
"securityType": "TrustedLaunch"
}
},
"copy": {
"name": "vmCopy",
"count": "[length(parameters('vmsToUpgrade').virtualMachines)]"
}
}
]
}
- 编辑参数 json 文件,其中包含要使用
TrustedLaunch
安全类型更新的虚拟机。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmsToUpgrade": {
"value": {
"virtualMachines": [
{
"vmName": "myVm01",
"location": "chinanorth2",
"secureBootEnabled": true
},
{
"vmName": "myVm02",
"location": "chinanorth2",
"secureBootEnabled": true
}
]
}
}
}
}
参数文件定义
properties |
属性说明 |
示例模板值 |
vmName |
Azure 第 2 代 VM 的名称 |
"myVm" |
location |
Azure 第 2 代 VM 的位置 |
"chinanorth2" |
secureBootEnabled |
使用受信任启动安全类型启用安全启动 |
是 |
- 解除分配要更新的所有 Azure 第 2 代 VM。
Stop-AzVM -ResourceGroupName myResourceGroup -Name myVm01
- 执行 ARM 模板部署。
$resourceGroupName = "myResourceGroup"
$parameterFile = "folderPathToFile\parameters.json"
$templateFile = "folderPathToFile\template.json"
New-AzResourceGroupDeployment `
-ResourceGroupName $resourceGroupName `
-TemplateFile $templateFile -TemplateParameterFile $parameterFile
- 验证部署是否成功。 使用 Azure 门户查看 VM 的安全类型和 UEFI 设置。 查看“概述”页中的“安全类型”部分。
- 启动已升级的受信任启动 VM,确保它已成功启动,并验证是否能够使用 RDP(对于 Windows VM)或 SSH(对于 Linux VM)登录 VM。