本節將逐步引導您使用 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 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 -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 上啟用可信啟動。
Azure Resource Manager 範本是一個 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)]"
}
}
]
}
- 透過使用
TrustedLaunch
安全性類型更新的虛擬機器來編輯參數 json 檔案。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmsToUpgrade": {
"value": {
"virtualMachines": [
{
"vmName": "myVm01",
"location": "westus3",
"secureBootEnabled": true
},
{
"vmName": "myVm02",
"location": "westus3",
"secureBootEnabled": true
}
]
}
}
}
}
參數檔案定義
屬性 |
屬性描述 |
範例範本值 |
vmName |
Azure 第 2 代 VM 的名稱 |
"myVm" |
location |
Azure 第 2 代 VM 的位置 |
"westus3" |
secureBootEnabled |
使用可信啟動安全性類型啟用安全開機 |
true |
- 解除配置所有要更新的 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。