快速入门:使用 ARM 模板在 Azure 门户中创建仪表板Quickstart: Create a dashboard in the Azure portal by using an ARM template

Azure 门户中的仪表板可以集中且有组织地呈现你的云资源。A dashboard in the Azure portal is a focused and organized view of your cloud resources. 本快速入门将重点介绍部署 Azure 资源管理器模板(ARM 模板)以创建仪表板的过程。This quickstart focuses on the process of deploying an Azure Resource Manager template (ARM template) to create a dashboard. 仪表板会显示虚拟机 (VM) 的性能以及一些静态信息和链接。The dashboard shows the performance of a virtual machine (VM), as well as some static information and links.

ARM 模板是定义项目基础结构和配置的 JavaScript 对象表示法 (JSON) 文件。An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. 该模板使用声明性语法,使你可以声明要部署的内容,而不需要编写一系列编程命令来进行创建。The template uses declarative syntax, which lets you state what you intend to deploy without having to write the sequence of programming commands to create it.

如果你的环境满足先决条件,并且你熟悉如何使用 ARM 模板,请选择“部署到 Azure”按钮。If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. Azure 门户中会打开模板。The template will open in the Azure portal.

部署到 AzureDeploy to Azure

先决条件Prerequisites

  • 如果没有 Azure 订阅,可在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.
  • 现有 VM。An existing VM.

创建虚拟机Create a virtual machine

在本快速入门的下一部分中创建的仪表板需要一台现有 VM。The dashboard you create in the next part of this quickstart requires an existing VM. 按照以下步骤创建 VM。Create a VM by following these steps.

  1. 在 Azure PowerShell 中。In Azure PowerShell.

  2. 复制以下命令,然后在命令提示符中输入该命令以创建资源组。Copy the following command and enter it at the command prompt to create a resource group.

    New-AzResourceGroup -Name SimpleWinVmResourceGroup -Location ChinaEast2
    

    将命令复制到命令提示符中

  3. 复制以下命令,然后在命令提示符中输入该命令以在资源组中创建 VM。Copy the following command and enter it at the command prompt to create a VM in the resource group.

    New-AzVm `
        -ResourceGroupName "SimpleWinVmResourceGroup" `
        -Name "SimpleWinVm" `
        -Location "China East 2"
    
  4. 输入 VM 的用户名和密码。Enter a username and password for the VM. 这是一个新的用户名和密码;它不是用于登录 Azure 的帐户。This is a new user name and password; it's not, for example, the account you use to sign in to Azure. 有关详细信息,请参阅用户名要求密码要求For more information, see username requirements and password requirements.

    VM 部署现在将开始进行,通常需要几分钟才能完成。The VM deployment now starts and typically takes a few minutes to complete. 部署完成后,请转到下一部分。After deployment completes, move on to the next section.

查看模板Review the template

本快速入门中使用的模板来自 Azure 快速启动模板The template used in this quickstart is from Azure Quickstart Templates. 本文的模板太长,无法在此处显示。The template for this article is too long to show here. 若要查看模板,请参阅 azuredeploy.jsonTo view the template, see azuredeploy.json. 模板 Microsoft.Portal/dashboards 中定义了一个 Azure 资源 - 在 Azure 门户中创建仪表板。One Azure resource is defined in the template, Microsoft.Portal/dashboards - Create a dashboard in the Azure portal.

部署模板Deploy the template

  1. 选择下图登录到 Azure 并打开一个模板。Select the following image to sign in to Azure and open a template.

    部署到 AzureDeploy to Azure

  2. 选择或输入以下值,然后选择“查看 + 创建”。Select or enter the following values, then select Review + create.

    ARM 模板、创建仪表板、部署门户

    除非另有指定,否则请使用默认值创建仪表板。Unless it's specified, use the default values to create the dashboard.

    • 订阅:选择一个 Azure 订阅。Subscription: select an Azure subscription.
    • 资源组:选择“SimpleWinVmResourceGroup”。Resource group: select SimpleWinVmResourceGroup.
    • 位置:选择“中国东部 2”。Location: select China East 2.
    • 虚拟机名称:输入“SimpleWinVm”。Virtual Machine Name: enter SimpleWinVm.
    • 虚拟机资源组:输入“SimpleWinVmResourceGroup”。Virtual Machine Resource Group: enter SimpleWinVmResourceGroup.
  3. 选择“创建”或“购买”。 Select Create or Purchase. 仪表板部署成功后,你会收到一条通知:After the dashboard has been deployed successfully, you get a notification:

    ARM 模板、创建仪表板、部署门户通知

我们使用了 Azure 门户来部署模板。The Azure portal was used to deploy the template. 除了 Azure 门户之外,还可以使用 Azure PowerShell、Azure CLI 和 REST API。In addition to the Azure portal, you can also use Azure PowerShell, Azure CLI, and REST API. 若要了解其他部署方法,请参阅部署模板To learn other deployment methods, see Deploy templates.

查看已部署的资源Review deployed resources

检查仪表板是否已成功创建,以及是否可以从 VM 中查看数据。Check that the dashboard was created successfully and that you can see data from the VM.

  1. 在 Azure 门户中,选择“仪表板”。In the Azure portal, select Dashboard.

    Azure 门户导航到仪表板

  2. 在仪表板页面上,选择“简单的 VM 仪表板”。On the dashboard page, select Simple VM Dashboard.

    导航到“简单的 VM 仪表板”

  3. 查看 ARM 模板创建的仪表板。Review the dashboard that the ARM template created. 你可以看到某些内容是静态的,但也有一些图表显示了你在一开始创建的 VM 的性能。You can see that some of the content is static, but there are also charts that show the performance of the VM you created at the beginning.

    查看简单的 VM 仪表板

清理资源Clean up resources

如果要删除 VM 和相关的仪表板,请删除包含它们的资源组。If you want to remove the VM and associated dashboard, delete the resource group that contains them.

  1. 在 Azure 门户中,搜索“SimpleWinVmResourceGroup”,然后在搜索结果中选中它。In the Azure portal, search for SimpleWinVmResourceGroup, then select it in the search results.

  2. 在“SimpleWinVmResourceGroup”页上,选择“删除资源组”,输入确认要删除的资源组名称,然后选择“删除” 。On the SimpleWinVmResourceGroup page, select Delete resource group, enter the resource group name to confirm, then select Delete.

    删除资源组

后续步骤Next steps

有关 Azure 门户中的仪表板的详细信息,请参阅:For more information about dashboards in the Azure portal, see: