|
| 1 | +--- |
| 2 | +title: "Workbook" |
| 3 | +description: Get started with Azure Monitor Workbooks on LocalStack |
| 4 | +template: doc |
| 5 | +--- |
| 6 | + |
| 7 | +import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage"; |
| 8 | + |
| 9 | +## Introduction |
| 10 | + |
| 11 | +Azure Monitor Workbooks are interactive reports that combine text, KQL queries, metrics, and visualizations into a single shareable document. |
| 12 | +Workbook templates are Azure Resource Manager resources that package reusable definitions and gallery metadata so teams can publish templates to experiences such as Azure Monitor workbooks galleries. |
| 13 | +They are commonly used to create operational dashboards, cost reports, and compliance summaries that surface data from multiple Azure Monitor sources. For more information, see [Azure Workbooks overview](https://learn.microsoft.com/en-us/azure/azure-monitor/visualize/workbooks-overview). |
| 14 | + |
| 15 | +LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Monitor Workbooks. |
| 16 | +The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Workbooks' integration with LocalStack. |
| 17 | + |
| 18 | +## Getting started |
| 19 | + |
| 20 | +This guide walks you through creating a workbook and a workbook template. |
| 21 | + |
| 22 | +Launch LocalStack using your preferred method. For more information, see [Introduction to LocalStack for Azure](/azure/getting-started/). Once the container is running, enable Azure CLI interception by running: |
| 23 | + |
| 24 | +```bash |
| 25 | +azlocal start-interception |
| 26 | +``` |
| 27 | + |
| 28 | +This command points the `az` CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API. |
| 29 | +To revert this configuration, run: |
| 30 | + |
| 31 | +```bash |
| 32 | +azlocal stop-interception |
| 33 | +``` |
| 34 | + |
| 35 | +This reconfigures the `az` CLI to send commands to the official Azure management REST API. |
| 36 | + |
| 37 | +### Create a resource group |
| 38 | + |
| 39 | +Create a resource group to hold all resources created in this guide: |
| 40 | + |
| 41 | +```bash |
| 42 | +az group create --name rg-workbook-demo --location westeurope |
| 43 | +``` |
| 44 | + |
| 45 | +```bash title="Output" |
| 46 | +{ |
| 47 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-workbook-demo", |
| 48 | + "location": "westeurope", |
| 49 | + "name": "rg-workbook-demo", |
| 50 | + "properties": { "provisioningState": "Succeeded" }, |
| 51 | + "type": "Microsoft.Resources/resourceGroups" |
| 52 | +} |
| 53 | +``` |
| 54 | +
|
| 55 | +### Create a workbook |
| 56 | +
|
| 57 | +Generate a UUID for the workbook name, then create a shared workbook: |
| 58 | +
|
| 59 | +```bash |
| 60 | +WORKBOOK_ID=$(python3 -c "import uuid; print(uuid.uuid4())") |
| 61 | + |
| 62 | +az monitor app-insights workbook create \ |
| 63 | + --name "$WORKBOOK_ID" \ |
| 64 | + --resource-group rg-workbook-demo \ |
| 65 | + --display-name "My Workbook" \ |
| 66 | + --kind shared \ |
| 67 | + --category workbook \ |
| 68 | + --version "Notebook/1.0" \ |
| 69 | + --serialized-data '{"version":"Notebook/1.0","items":[{"type":1,"content":{"json":"## My Workbook\nHello, world!"},"name":"text-0"}],"isLocked":false}' \ |
| 70 | + --location westeurope |
| 71 | +``` |
| 72 | +
|
| 73 | +```bash title="Output" |
| 74 | +{ |
| 75 | + "category": "workbook", |
| 76 | + "displayName": "My Workbook", |
| 77 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-workbook-demo/providers/Microsoft.Insights/workbooks/de747180-ecea-4b97-bef4-f8376fc72abe", |
| 78 | + "kind": "shared", |
| 79 | + "location": "westeurope", |
| 80 | + "name": "de747180-ecea-4b97-bef4-f8376fc72abe", |
| 81 | + "serializedData": "{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"## My Workbook\\nHello, world!\"},\"name\":\"text-0\"}],\"isLocked\":false}", |
| 82 | + "type": "Microsoft.Insights/workbooks", |
| 83 | + "version": "Notebook/1.0" |
| 84 | +} |
| 85 | +``` |
| 86 | +
|
| 87 | +### List workbooks |
| 88 | +
|
| 89 | +List all workbooks in the resource group filtered by category: |
| 90 | +
|
| 91 | +```bash |
| 92 | +az monitor app-insights workbook list \ |
| 93 | + --resource-group rg-workbook-demo \ |
| 94 | + --category workbook |
| 95 | +``` |
| 96 | +
|
| 97 | +```bash title="Output" |
| 98 | +[ |
| 99 | + { |
| 100 | + "category": "workbook", |
| 101 | + "displayName": "My Workbook", |
| 102 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-workbook-demo/providers/Microsoft.Insights/workbooks/de747180-ecea-4b97-bef4-f8376fc72abe", |
| 103 | + "kind": "shared", |
| 104 | + "location": "westeurope", |
| 105 | + "name": "de747180-ecea-4b97-bef4-f8376fc72abe", |
| 106 | + "serializedData": "...", |
| 107 | + "type": "Microsoft.Insights/workbooks", |
| 108 | + "version": "Notebook/1.0" |
| 109 | + } |
| 110 | +] |
| 111 | +``` |
| 112 | +
|
| 113 | +### Create a workbook template |
| 114 | +
|
| 115 | +Workbook templates are not exposed as a first-party `az monitor app-insights` command group. Use `az rest` against the resource manager endpoint (via your active cloud, which LocalStack updates when interception is enabled): |
| 116 | +
|
| 117 | +```bash |
| 118 | +RM=$(az cloud show --query "endpoints.resourceManager" -o tsv | sed 's|/$||') |
| 119 | + |
| 120 | +az rest --method PUT \ |
| 121 | + --url "${RM}/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-workbook-demo/providers/microsoft.insights/workbookTemplates/my-template?api-version=2020-11-20" \ |
| 122 | + --body '{ |
| 123 | + "location": "westeurope", |
| 124 | + "properties": { |
| 125 | + "priority": 1, |
| 126 | + "author": "My Team", |
| 127 | + "templateData": { |
| 128 | + "version": "Notebook/1.0", |
| 129 | + "items": [] |
| 130 | + }, |
| 131 | + "galleries": [ |
| 132 | + { |
| 133 | + "name": "My Template", |
| 134 | + "category": "General", |
| 135 | + "type": "workbook", |
| 136 | + "order": 100, |
| 137 | + "resourceType": "Azure Monitor" |
| 138 | + } |
| 139 | + ] |
| 140 | + } |
| 141 | + }' |
| 142 | +``` |
| 143 | +
|
| 144 | +```bash title="Output" |
| 145 | +{ |
| 146 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-workbook-demo/providers/Microsoft.Insights/workbookTemplates/my-template", |
| 147 | + "location": "westeurope", |
| 148 | + "name": "my-template", |
| 149 | + "properties": { |
| 150 | + "author": "My Team", |
| 151 | + "galleries": [ |
| 152 | + { |
| 153 | + "category": "General", |
| 154 | + "name": "My Template", |
| 155 | + "order": 100, |
| 156 | + "resourceType": "Azure Monitor", |
| 157 | + "type": "workbook" |
| 158 | + } |
| 159 | + ], |
| 160 | + "priority": 1, |
| 161 | + "templateData": { |
| 162 | + "version": "Notebook/1.0", |
| 163 | + "items": [] |
| 164 | + } |
| 165 | + }, |
| 166 | + "type": "Microsoft.Insights/workbookTemplates" |
| 167 | +} |
| 168 | +``` |
| 169 | +
|
| 170 | +### Delete resources |
| 171 | +
|
| 172 | +Delete the workbook and workbook template, then delete the resource group. Use the same shell session as earlier steps so `WORKBOOK_ID` and `RM` are still set. |
| 173 | +
|
| 174 | +```bash |
| 175 | +az monitor app-insights workbook delete \ |
| 176 | + --name "$WORKBOOK_ID" \ |
| 177 | + --resource-group rg-workbook-demo \ |
| 178 | + --yes |
| 179 | + |
| 180 | +az rest --method DELETE \ |
| 181 | + --url "${RM}/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-workbook-demo/providers/microsoft.insights/workbookTemplates/my-template?api-version=2020-11-20" |
| 182 | + |
| 183 | +az group delete --name rg-workbook-demo --yes |
| 184 | +``` |
| 185 | +
|
| 186 | +## Features |
| 187 | +
|
| 188 | +- **Workbook lifecycle:** Create, read, list, update, and delete workbooks. |
| 189 | +- **Workbook template lifecycle:** Create, read, list, update, and delete workbook templates. |
| 190 | +- **Shared and private workbooks:** The [Workbooks REST API](https://learn.microsoft.com/en-us/rest/api/application-insights/workbooks/create-or-update) defines `kind` values `shared` and `user`. The Azure CLI `workbook create` command currently exposes only `--kind shared` (see [az monitor app-insights workbook create](https://learn.microsoft.com/en-us/cli/azure/monitor/app-insights/workbook#az-monitor-app-insights-workbook-create)). |
| 191 | +- **Category filtering:** For [list by resource group](https://learn.microsoft.com/en-us/rest/api/application-insights/workbooks/list-by-resource-group), the `category` query parameter is one of `workbook`, `TSG`, `performance`, or `retention` (the same set the CLI accepts on `workbook list --category`). The `properties.category` value stored on a workbook resource is a separate string that you set at creation time. |
| 192 | +- **Serialized data storage:** Store the full workbook JSON definition in the `serializedData` field. |
| 193 | +- **Gallery configuration:** Define workbook templates with gallery metadata for easy discovery. |
| 194 | +
|
| 195 | +## Limitations |
| 196 | +
|
| 197 | +- **No rendering or query execution:** The workbook content is stored as a JSON string but KQL queries within the workbook are not executed. |
| 198 | +- **No Azure Portal integration:** Workbooks cannot be previewed or rendered via LocalStack. |
| 199 | +- **No linked resource validation:** Source ID references to Application Insights components or subscriptions are accepted but not validated. |
| 200 | +
|
| 201 | +## Samples |
| 202 | +
|
| 203 | +Explore end-to-end examples in the [LocalStack for Azure Samples](https://github.com/localstack/localstack-azure-samples) repository. |
| 204 | +
|
| 205 | +## API Coverage |
| 206 | +
|
| 207 | +<AzureFeatureCoverage service="Microsoft.Insights" client:load /> |
0 commit comments