|
| 1 | +--- |
| 2 | +title: Create an Azure portal dashboard by using a Bicep file |
| 3 | +description: Learn how to create an Azure portal dashboard by using a Bicep file. |
| 4 | +ms.topic: quickstart |
| 5 | +ms.custom: subject-bicepqs, |
| 6 | +ms.date: 09/15/2022 |
| 7 | +--- |
| 8 | + |
| 9 | +# Quickstart: Create a dashboard in the Azure portal by using a Bicep file |
| 10 | + |
| 11 | +A dashboard in the Azure portal is a focused and organized view of your cloud resources. This quickstart focuses on the process of deploying a Bicep file to create a dashboard. The dashboard shows the performance of a virtual machine (VM), and some static information and links. |
| 12 | + |
| 13 | +[!INCLUDE [About Bicep](../../includes/resource-manager-quickstart-bicep-introduction.md)] |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 18 | +- [Azure PowerShell](/powershell/azure/install-az-ps) or [Azure CLI](/cli/azure/install-azure-cli). |
| 19 | + |
| 20 | +## Review the Bicep file |
| 21 | + |
| 22 | +The Bicep file used in this quickstart is from [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/azure-portal-dashboard/). The Bicep file for this article is too long to show here. To view the Bicep file, see [main.bicep](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.portal/azure-portal-dashboard/main.bicep). The Bicep file defines one Azure resource, a dashboard that displays data about the VM you created: |
| 23 | + |
| 24 | +- [Microsoft.Portal/dashboards](/azure/templates/microsoft.portal/dashboards?pivots=deployment-language-bicep) |
| 25 | + |
| 26 | +## Deploy the Bicep file |
| 27 | + |
| 28 | +1. Save the Bicep file as **main.bicep** to your local computer. |
| 29 | +1. Deploy the Bicep file using either Azure CLI or Azure PowerShell. |
| 30 | + # [CLI](#tab/CLI) |
| 31 | + |
| 32 | + ```azurecli |
| 33 | + $resourceGroupName = 'SimpleWinVmResourceGroup' |
| 34 | + $location = 'eastus' |
| 35 | + $adminUserName = '<admin-user-name>' |
| 36 | + $adminPassword = '<admin-password>' |
| 37 | + $dnsLabelPrefix = '<dns-label-prefix>' |
| 38 | + $virtualMachineName = 'SimpleWinVM' |
| 39 | + $vmTemplateUri = 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.portal/azure-portal-dashboard/prereqs/prereq.azuredeploy.json' |
| 40 | +
|
| 41 | + az group create --name $resourceGroupName --location $location |
| 42 | + az deployment group create --resource-group $resourceGroupName --template-uri $vmTemplateUri --parameters adminUsername=$adminUserName adminPassword=$adminPassword dnsLabelPrefix=$dnsLabelPrefix |
| 43 | + az deployment group create --resource-group $resourceGroupName --template-file main.bicep --parameters virtualMachineName=$virtualMachineName virtualMachineResourceGroup=$resourceGroupName |
| 44 | + ``` |
| 45 | +
|
| 46 | + # [PowerShell](#tab/PowerShell) |
| 47 | +
|
| 48 | + ```azurepowershell |
| 49 | + $resourceGroupName = 'SimpleWinVmResourceGroup' |
| 50 | + $location = 'eastus' |
| 51 | + $adminUserName = '<admin-user-name>' |
| 52 | + $adminPassword = '<admin-password>' |
| 53 | + $dnsLabelPrefix = '<dns-label-prefix>' |
| 54 | + $virtualMachineName = 'SimpleWinVM' |
| 55 | + $vmTemplateUri = 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.portal/azure-portal-dashboard/prereqs/prereq.azuredeploy.json' |
| 56 | +
|
| 57 | + $encrypted = ConvertTo-SecureString -string $adminPassword -AsPlainText |
| 58 | +
|
| 59 | + New-AzResourceGroup -Name $resourceGroupName -Location $location |
| 60 | + New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $vmTemplateUri -adminUsername $adminUserName -adminPassword $encrypted -dnsLabelPrefix $dnsLabelPrefix |
| 61 | + New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile ./main.bicep -virtualMachineName $virtualMachineName -virtualMachineResourceGroup $resourceGroupName |
| 62 | + ``` |
| 63 | +
|
| 64 | + --- |
| 65 | +
|
| 66 | + Replace the following values in the script: |
| 67 | +
|
| 68 | + - <admin-user-name>: specify an administrator username. |
| 69 | + - <admin-password>: specify an administrator password. |
| 70 | + - <dns-label-prefix>: specify a DNS prefix. |
| 71 | +
|
| 72 | + The Bicep file requires an existing virtual machine. Before deploying the Bicep file, the script deploys an ARM template located at *https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.portal/azure-portal-dashboard/prereqs/prereq.azuredeploy.json* for creating a virtual machine. The virtual machine name is hard-coded as **SimpleWinVM** in the ARM template. |
| 73 | +
|
| 74 | +When the deployment finishes, you should see a message indicating the deployment succeeded. |
| 75 | +
|
| 76 | +## Review deployed resources |
| 77 | +
|
| 78 | +[!INCLUDE [azure-portal-review-deployed-resources](../../includes/azure-portal-review-deployed-resources.md)] |
| 79 | +
|
| 80 | +## Clean up resources |
| 81 | +
|
| 82 | +If you want to remove the VM and associated dashboard, delete the resource group that contains them. |
| 83 | +
|
| 84 | +1. In the Azure portal, search for **SimpleWinVmResourceGroup**, then select it in the search results. |
| 85 | +
|
| 86 | +1. On the **SimpleWinVmResourceGroup** page, select **Delete resource group**, enter the resource group name to confirm, then select **Delete**. |
| 87 | +
|
| 88 | +> [!CAUTION] |
| 89 | +> Deleting a resource group will delete all of the resources contained within it. If the resource group contains additional resources aside from your virtual machine and dashboard, those resources will also be deleted. |
| 90 | +
|
| 91 | +## Next steps |
| 92 | +
|
| 93 | +For more information about dashboards in the Azure portal, see: |
| 94 | +
|
| 95 | +> [!div class="nextstepaction"] |
| 96 | +> [Create and share dashboards in the Azure portal](azure-portal-dashboards.md) |
0 commit comments