During Public Preview you can use the Team plan for free, and get an early-adopter discount at GA. Sign in
Deploying a Portal Dashboard
This guide shows you how to deploy a Portal Dashboard against Locally, view it in the Locally Dashboard and then add a tile to it. As with the other guides we're going to use the Azure CLI, but the same resources can be provisioned with HashiCorp Terraform, Pulumi or Bicep too.
Before you start
- The Azure CLI (
az) installed. - Locally installed, with Locally Setup completed.
The az portal commands live in an Azure CLI extension. Locally keeps its own set of extensions, so add it through locally run:
$
locally run az extension add --name portal
1. Start Locally
Firstly, we need to launch Locally which we can do from a terminal by running:
$
locally build
Once Locally has started, the Locally Dashboard will open automatically:
2. Create a Resource Group
Next we can create the Resource Group:
$
locally run az group create -n sample-dashboards -l berlin
There's two things to note here:
- The Azure CLI supports Automatic Configuration, meaning that it can automatically be configured to work against Locally just by prefixing commands with
locally run. - Locally intentionally uses a different set of locations to Azure as a safety precaution, so that you can be confident you're deploying against Locally rather than regular Azure. You can also configure Locally to use the Azure locations too, but you'll want to be extra sure that you're prefixing commands with
locally runwhen you do.
3. Create something to show
A dashboard is more useful with something on it, so we'll add a Managed Identity to the Resource Group for it to list:
$
locally run az identity create -g sample-dashboards -n sample-identity --query "{name:name, type:type}"
{
"name": "sample-identity",
"type": "Microsoft.ManagedIdentity/userAssignedIdentities"
}
4. Write the dashboard
A dashboard is a list of tiles (which Azure calls parts), each with a position on a grid. This one has four: a markdown note, a clock, the number of resources in the Resource Group from a Resource Graph query, and a list of the resources themselves. Save it as dashboard.json:
{
"lenses": [
{
"order": 0,
"parts": [
{
"position": { "x": 0, "y": 0, "colSpan": 6, "rowSpan": 2 },
"metadata": {
"inputs": [],
"type": "Extension/HubsExtension/PartType/MarkdownPart",
"settings": {
"content": {
"title": "Sample app",
"subtitle": "Team dashboard",
"content": "Everything the sample app runs on lives in the **sample-dashboards** resource group.\n\n- Deploy with `locally run az deployment group create`\n- Tidy up with `locally run az group delete`"
}
}
}
},
{
"position": { "x": 6, "y": 0, "colSpan": 2, "rowSpan": 2 },
"metadata": {
"inputs": [
{ "name": "timezoneId", "value": "Europe/Berlin" },
{ "name": "timeFormat", "value": "HH:mm" }
],
"type": "Extension/HubsExtension/PartType/ClockPart"
}
},
{
"position": { "x": 8, "y": 0, "colSpan": 2, "rowSpan": 2 },
"metadata": {
"inputs": [
{ "name": "partTitle", "value": "Resources" },
{ "name": "query", "value": "resources | where resourceGroup == 'sample-dashboards' | summarize count()" }
],
"type": "Extension/HubsExtension/PartType/ArgQuerySingleValueTile"
}
},
{
"position": { "x": 0, "y": 2, "colSpan": 6, "rowSpan": 3 },
"metadata": {
"inputs": [
{ "name": "resourceGroup", "value": "sample-dashboards" }
],
"type": "Extension/HubsExtension/PartType/ResourceGroupMapPinnedPart"
}
}
]
}
],
"metadata": {
"model": {
"timeRange": {
"value": { "relative": { "duration": 24, "timeUnit": 1 } },
"type": "MsPortalFx.Composition.Configuration.ValueTypes.TimeRange"
}
}
}
}
5. Create the dashboard
Now we can create the dashboard from that file:
$
locally run az portal dashboard create -g sample-dashboards -n sample-dashboard --input-path dashboard.json --query "{name:name, location:location, tiles:length(properties.lenses[0].parts)}"
{
"location": "berlin",
"name": "sample-dashboard",
"tiles": 4
}
6. View it in the Locally Dashboard
Locally draws the dashboard for you. In the Locally Dashboard, open Monitoring, then the Dashboards tab, and pick sample-dashboard from the list in the top-right:
The tiles Locally draws are markdown, clocks, Resource Graph queries, resources and lists of resources, metrics charts, Log Analytics and Application Insights queries, and the Application Insights overview tiles. Any other tile shows as a labelled placeholder in its place, as does a markdown tile that loads its content from a URL.
Note
7. Add a tile
This tile is a table of the resources in the Resource Group by type. Add it to the end of the parts list in dashboard.json:
{
"position": { "x": 6, "y": 2, "colSpan": 4, "rowSpan": 3 },
"metadata": {
"inputs": [
{ "name": "partTitle", "value": "Resources by type" },
{ "name": "query", "value": "resources | where resourceGroup == 'sample-dashboards' | summarize Count = count() by Type = type" }
],
"type": "Extension/HubsExtension/PartType/ArgQueryGridTile"
}
}
Then update the dashboard from the file:
$
locally run az portal dashboard update -g sample-dashboards -n sample-dashboard --input-path dashboard.json --query "{name:name, tiles:length(properties.lenses[0].parts)}"
{
"name": "sample-dashboard",
"tiles": 5
}
Reload the page in the Locally Dashboard and the new tile is there:
8. List the dashboards
To see the dashboards in the Resource Group:
$
locally run az portal dashboard list -g sample-dashboards --query "[].{Name:name, Location:location, Tiles:length(properties.lenses[0].parts)}" -o table
Name Location Tiles
---------------- ---------- -------
sample-dashboard berlin 5
Doing this with other tooling
Whilst this guide used the Azure CLI, dashboards work the same way through any of the tooling that Locally supports - a Microsoft.Portal/dashboards resource in HashiCorp Terraform or OpenTofu, Pulumi, Bicep or an ARM Template all provision against Locally in the same way, with only the location changed.
Next steps
To write your own queries for Resource Graph tiles, see Resource Graph. To deploy a dashboard alongside the resources it shows, see ARM Deployments.
Should you encounter any issues, please take a look at the troubleshooting section, reach out in our Discord or open an issue and we'll take a look.
Resource types this guide uses
These are the Azure resource types this guide creates in Locally:
During Public Preview you can use the Team plan for free, and get an early-adopter discount at GA. Sign in