Azure 启动诊断Azure boot diagnostics

启动诊断是 Azure 虚拟机 (VM) 的一项调试功能,可用于诊断 VM 启动故障。Boot diagnostics is a debugging feature for Azure virtual machines (VM) that allows diagnosis of VM boot failures. 启动诊断使用户能够通过收集串行日志信息和屏幕截图来观察其 VM 在启动时的状态。Boot diagnostics enables a user to observe the state of their VM as it is booting up by collecting serial log information and screenshots.

启动诊断存储帐户Boot diagnostics storage account

在 Azure 门户中创建 VM 时,默认情况下会启用“启动诊断”。When creating a VM in Azure portal, boot diagnostics is enabled by default. 建议的启动诊断体验是使用托管存储帐户,因为它可以在创建 Azure VM 时显著提高性能。The recommended boot diagnostics experience is to use a managed storage account, as it yields significant performance improvements in the time to create an Azure VM. 这是因为将要使用 Azure 托管存储帐户,从而节省了创建新的用户存储帐户来存储启动诊断数据所需的时间。This is because an Azure managed storage account will be used, removing the time it takes to create a new user storage account to store the boot diagnostics data.

另一种启动诊断体验是使用用户管理的存储帐户。An alternative boot diagnostics experience is to use a user managed storage account. 用户可以创建新的存储帐户,也可以使用现有的存储帐户。A user can either create a new storage account or use an existing one.

重要

启动诊断数据 blob(包括日志和快照映像)存储在托管存储帐户中。The boot diagnostics data blobs (which comprise of logs and snapshot images) are stored in a managed storage account. 将仅对 blob 使用的 GiB 向客户收费,而不是根据磁盘的预配大小收费。Customers will be charged only on used GiBs by the blobs, not on the disk's provisioned size. 快照计量将用于托管存储帐户的计费。The snapshot meters will be used for billing of the managed storage account. 由于托管帐户是在标准 LRS 或标准 ZRS 上创建的,因此,仅针对诊断数据 blob 的大小按每月 $0.05/GB 向客户收费。Because the managed accounts are created on either Standard LRS or Standard ZRS, customers will be charged at $0.05/GB per month for the size of their diagnostic data blobs only. 有关此定价的详细信息,请参阅托管磁盘定价For more information on this pricing, see Managed disks pricing. 客户将看到这一费用与其 VM 资源 URI 相关联。Customers will see this charge tied to their VM resource URI.

启动诊断视图Boot diagnostics view

虚拟机边栏选项卡中的启动诊断选项位于 Azure 门户的“支持和故障排除”部分。Located in the virtual machine blade, the boot diagnostics option is under the Support and Troubleshooting section in the Azure portal. 选择启动诊断会显示屏幕截图和串行日志信息。Selecting boot diagnostics will display a screenshot and serial log information. 串行日志包含内核消息,屏幕快照是 VM 当前状态的快照。The serial log contains kernel messaging and the screenshot is a snapshot of your VMs current state. Windows 或 Linux 会根据 VM 是否正在运行来确定预期的屏幕快照会是什么样子。Based on if the VM is running Windows or Linux determines what the expected screenshot would look like. Windows 用户会看到桌面背景,Linux 用户会看到登录提示。For Windows, users will see a desktop background and for Linux, users will see a login prompt.

Linux 启动诊断的屏幕截图 Windows 启动诊断的屏幕截图

启用托管启动诊断Enable managed boot diagnostics

可以通过 Azure 门户、CLI 和 ARM 模板启用托管启动诊断。Managed boot diagnostics can be enabled through the Azure portal, CLI and ARM Templates. 尚不支持通过 PowerShell 进行启用。Enabling through PowerShell is not yet supported.

使用 Azure 门户启用托管启动诊断Enable managed boot diagnostics using the Azure portal

在 Azure 门户中创建 VM 时,默认设置是使用托管存储帐户启用启动诊断。When creating a VM in the Azure portal, the default setting is to have boot diagnostics enabled using a managed storage account. 若要查看此设置,请在创建 VM 的过程中导航到“管理”选项卡。To view this, navigate to the Management tab during the VM creation.

屏幕截图显示了如何在创建 VM 期间启用托管启动诊断。

使用 CLI 启用托管启动诊断Enable managed boot diagnostics using CLI

Azure CLI 2.12.0 及更高版本支持启动诊断使用托管存储帐户。Boot diagnostics with a managed storage account is supported in Azure CLI 2.12.0 and later. 如果不输入存储帐户的名称或 URI,则会使用托管帐户。If you do not input a name or URI for a storage account, a managed account will be used. 有关详细信息和代码示例,请参阅适用于启动诊断的 CLI 文档For more information and code samples see the CLI documentation for boot diagnostics.

使用 Azure 资源管理器 (ARM) 模板启用托管启动诊断Enable managed boot diagnostics using Azure Resource Manager (ARM) templates

API 版本 2020-06-01 后的所有内容都支持托管启动诊断。Everything after API version 2020-06-01 supports managed boot diagnostics. 有关详细信息,请参阅启动诊断实例视图For more information, see boot diagnostics instance view.

            "name": "[parameters('virtualMachineName')]",
            "type": "Microsoft.Compute/virtualMachines",
            "apiVersion": "2020-06-01",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
            ],
            "properties": {
                "hardwareProfile": {
                    "vmSize": "[parameters('virtualMachineSize')]"
                },
                "storageProfile": {
                    "osDisk": {
                        "createOption": "fromImage",
                        "managedDisk": {
                            "storageAccountType": "[parameters('osDiskType')]"
                        }
                    },
                    "imageReference": {
                        "publisher": "Canonical",
                        "offer": "UbuntuServer",
                        "sku": "18.04-LTS",
                        "version": "latest"
                    }
                },
                "networkProfile": {
                    "networkInterfaces": [
                        {
                            "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
                        }
                    ]
                },
                "osProfile": {
                    "computerName": "[parameters('virtualMachineComputerName')]",
                    "adminUsername": "[parameters('adminUsername')]",
                    "linuxConfiguration": {
                        "disablePasswordAuthentication": true
                    }
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true
                    }
                }
            }
        }
    ],

限制Limitations

  • 启动诊断仅适用于 Azure 资源管理器 VM。Boot diagnostics is only available for Azure Resource Manager VMs.

  • 托管启动诊断不支持那些使用非托管 OS 磁盘的 VM。Managed boot diagnostics does not support VMs using unmanaged OS disks.

  • 启动诊断不支持高级存储帐户。如果将高级存储帐户用于启动诊断,则在启动 VM 时,用户会收到 StorageAccountTypeNotSupported 错误。Boot diagnostics does not support premium storage accounts, if a premium storage account is used for boot diagnostics users will receive an StorageAccountTypeNotSupported error when starting the VM.

  • 资源管理器 API 版本“2020-06-01”及更高版本支持托管存储帐户。Managed storage accounts are supported in Resource Manager API version "2020-06-01" and later.

  • 对于单实例 VM,门户仅支持将启动诊断与托管存储帐户配合使用。Portal only supports the use of boot diagnostics with a managed storage account for single instance VMs.

后续步骤Next steps

详细了解如何使用启动诊断功能来排查 Azure 中虚拟机的问题Learn more about how to use boot diagnostics to troubleshoot virtual machines in Azure.