Quickstart: Create an Azure portal dashboard with Azure CLI
A dashboard in the Azure portal is a focused and organized view of your cloud resources. This article focuses on the process of using Azure CLI to create a dashboard. The dashboard shows the performance of a virtual machine (VM), as well as some static information and links.
Prerequisites
Use the Bash environment in Azure Cloud Shell.
If you prefer, install the Azure CLI to run CLI reference commands.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For additional sign-in options, see Sign in with the Azure CLI.
When you're prompted, install Azure CLI extensions on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
If you have multiple Azure subscriptions, choose the appropriate subscription in which to bill the resources. Select a subscription by using the az account set command:
az account set --subscription 00000000-0000-0000-0000-000000000000Create an Azure resource group by using the az group create command or use an existing resource group:
az group create --name myResourceGroup --location centralusA resource group is a logical container in which Azure resources are deployed and managed as a group.
Create a virtual machine
Create a virtual machine by using the az vm create command:
az vm create --resource-group myResourceGroup --name SimpleWinVM --image win2016datacenter \
--admin-username azureuser --admin-password 1StrongPassword$
Note
The password must be complex. 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.
The deployment starts and typically takes a few minutes to complete. After deployment completes, move on to the next section.
Download the dashboard template
Since Azure dashboards are resources, they can be represented as JSON. For more information, see The structure of Azure Dashboards.
Download the following file: portal-dashboard-template-testvm.json.
Customize the downloaded template by changing the following values to your values:
<subscriptionID>: Your subscription<rgName>: Resource group, for examplemyResourceGroup<vmName>: Virtual machine name, for exampleSimpleWinVM<dashboardTitle>: Dashboard title, for exampleSimple VM Dashboard<location>: Your Azure region, for example,centralus
For more information, see Microsoft portal dashboards template reference.
Deploy the dashboard template
You can now deploy the template from within Azure CLI.
Run the az portal dashboard create command to deploy the template:
az portal dashboard create --resource-group myResourceGroup --name 'Simple VM Dashboard' \ --input-path portal-dashboard-template-testvm.json --location centralusCheck that the dashboard was created successfully by running the az portal dashboard show command:
az portal dashboard show --resource-group myResourceGroup --name 'Simple VM Dashboard'
To see all the dashboards for the current subscription, use az portal dashboard list:
az portal dashboard list
You can also see all the dashboards for a resource group:
az portal dashboard list --resource-group myResourceGroup
You can update a dashboard by using the az portal dashboard update command:
az portal dashboard update --resource-group myResourceGroup --name 'Simple VM Dashboard' \
--input-path portal-dashboard-template-testvm.json --location centralus
Verify that you can see data about the virtual machine from within the Azure portal dashboard.
In the Azure portal, select Dashboard.
On the dashboard page, select Simple VM Dashboard.
Review the dashboard that the Azure Resource Manager template (ARM template) created. 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.
Clean up resources
To remove the virtual machine and associated dashboard, delete the resource group that contains them.
Caution
The following example deletes the specified resource group and all resources contained within it. If resources outside the scope of this article exist in the specified resource group, they will also be deleted.
az group delete --name myResourceGroup
To remove only the dashboard, use the az portal dashboard delete command:
az portal dashboard delete --resource-group myResourceGroup --name "Simple VM Dashboard"
Next steps
For more information about Azure CLI support for dashboards, see az portal dashboard.
