|
| 1 | +--- |
| 2 | +title: "Web Test" |
| 3 | +description: Get started with Azure Monitor Web Tests on LocalStack |
| 4 | +template: doc |
| 5 | +--- |
| 6 | + |
| 7 | +import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage"; |
| 8 | + |
| 9 | +## Introduction |
| 10 | + |
| 11 | +Azure Monitor Web Tests (availability tests) send HTTP probes to a URL from multiple geographic locations and alert when the endpoint is unavailable or slow. |
| 12 | +Web Tests are associated with an Application Insights component and report availability data alongside application telemetry. |
| 13 | +They are commonly used to monitor public-facing APIs and web applications for uptime and response time from a global perspective. For more information, see [Application Insights availability tests](https://learn.microsoft.com/en-us/azure/azure-monitor/app/availability-overview). |
| 14 | + |
| 15 | +LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Monitor Web Tests. |
| 16 | +The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Web Tests' integration with LocalStack. |
| 17 | + |
| 18 | +## Getting started |
| 19 | + |
| 20 | +This guide walks you through creating a web test linked to an Application Insights component. |
| 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-webtest-demo --location westeurope |
| 43 | +``` |
| 44 | + |
| 45 | +```bash title="Output" |
| 46 | +{ |
| 47 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-webtest-demo", |
| 48 | + "location": "westeurope", |
| 49 | + "name": "rg-webtest-demo", |
| 50 | + "properties": { "provisioningState": "Succeeded" }, |
| 51 | + "type": "Microsoft.Resources/resourceGroups" |
| 52 | +} |
| 53 | +``` |
| 54 | +
|
| 55 | +### Create an Application Insights component |
| 56 | +
|
| 57 | +Create an Application Insights component to attach the web test to: |
| 58 | +
|
| 59 | +```bash |
| 60 | +az monitor app-insights component create \ |
| 61 | + --app my-app-insights \ |
| 62 | + --resource-group rg-webtest-demo \ |
| 63 | + --location westeurope \ |
| 64 | + --kind web |
| 65 | +``` |
| 66 | +
|
| 67 | +```bash title="Output" |
| 68 | +{ |
| 69 | + "appId": "c62300bc-c7ae-5dd1-9f6c-08016bcbfbd9", |
| 70 | + "applicationType": "web", |
| 71 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-webtest-demo/providers/microsoft.insights/components/my-app-insights", |
| 72 | + "kind": "web", |
| 73 | + "location": "westeurope", |
| 74 | + "name": "my-app-insights", |
| 75 | + "provisioningState": "Succeeded", |
| 76 | + "resourceGroup": "rg-webtest-demo", |
| 77 | + "type": "microsoft.insights/components", |
| 78 | + ... |
| 79 | +} |
| 80 | +``` |
| 81 | +
|
| 82 | +### Create a web test |
| 83 | +
|
| 84 | +Retrieve the Application Insights resource ID, then create a standard availability test linked to it via a `hidden-link` tag: |
| 85 | +
|
| 86 | +```bash |
| 87 | +AI_ID=$(az monitor app-insights component show \ |
| 88 | + --app my-app-insights \ |
| 89 | + --resource-group rg-webtest-demo \ |
| 90 | + --query id \ |
| 91 | + --output tsv) |
| 92 | + |
| 93 | +az monitor app-insights web-test create \ |
| 94 | + --name my-web-test \ |
| 95 | + --resource-group rg-webtest-demo \ |
| 96 | + --location westeurope \ |
| 97 | + --defined-web-test-name "My Web Test" \ |
| 98 | + --web-test-kind standard \ |
| 99 | + --enabled true \ |
| 100 | + --frequency 300 \ |
| 101 | + --timeout 30 \ |
| 102 | + --locations Id=us-tx-sn1-azr \ |
| 103 | + --request-url "https://example.com" \ |
| 104 | + --http-verb GET \ |
| 105 | + --synthetic-monitor-id my-web-test \ |
| 106 | + --tags "hidden-link:$AI_ID=Resource" |
| 107 | +``` |
| 108 | +
|
| 109 | +```bash title="Output" |
| 110 | +{ |
| 111 | + "enabled": true, |
| 112 | + "frequency": 300, |
| 113 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-webtest-demo/providers/Microsoft.Insights/webtests/my-web-test", |
| 114 | + "kind": "standard", |
| 115 | + "location": "westeurope", |
| 116 | + "locations": [ |
| 117 | + { |
| 118 | + "Id": "us-tx-sn1-azr" |
| 119 | + } |
| 120 | + ], |
| 121 | + "name": "my-web-test", |
| 122 | + "request": { |
| 123 | + "httpVerb": "GET", |
| 124 | + "requestUrl": "https://example.com" |
| 125 | + }, |
| 126 | + "tags": { |
| 127 | + "hidden-link:/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-webtest-demo/providers/microsoft.insights/components/my-app-insights": "Resource" |
| 128 | + }, |
| 129 | + "timeout": 30, |
| 130 | + "type": "Microsoft.Insights/webtests", |
| 131 | + "webTestKind": "standard", |
| 132 | + "webTestName": "My Web Test" |
| 133 | +} |
| 134 | +``` |
| 135 | +
|
| 136 | +### Show a web test |
| 137 | +
|
| 138 | +Retrieve the details of a specific web test: |
| 139 | +
|
| 140 | +```bash |
| 141 | +az monitor app-insights web-test show \ |
| 142 | + --name my-web-test \ |
| 143 | + --resource-group rg-webtest-demo |
| 144 | +``` |
| 145 | +
|
| 146 | +```bash title="Output" |
| 147 | +{ |
| 148 | + "enabled": true, |
| 149 | + "frequency": 300, |
| 150 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-webtest-demo/providers/Microsoft.Insights/webtests/my-web-test", |
| 151 | + "kind": "standard", |
| 152 | + "location": "westeurope", |
| 153 | + "locations": [ |
| 154 | + { |
| 155 | + "Id": "us-tx-sn1-azr" |
| 156 | + } |
| 157 | + ], |
| 158 | + "name": "my-web-test", |
| 159 | + "request": { |
| 160 | + "httpVerb": "GET", |
| 161 | + "requestUrl": "https://example.com" |
| 162 | + }, |
| 163 | + "tags": { |
| 164 | + "hidden-link:/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-webtest-demo/providers/microsoft.insights/components/my-app-insights": "Resource" |
| 165 | + }, |
| 166 | + "timeout": 30, |
| 167 | + "type": "Microsoft.Insights/webtests", |
| 168 | + "webTestKind": "standard", |
| 169 | + "webTestName": "My Web Test" |
| 170 | +} |
| 171 | +``` |
| 172 | +
|
| 173 | +### List web tests |
| 174 | +
|
| 175 | +List all web tests in the resource group: |
| 176 | +
|
| 177 | +```bash |
| 178 | +az monitor app-insights web-test list \ |
| 179 | + --resource-group rg-webtest-demo |
| 180 | +``` |
| 181 | +
|
| 182 | +```bash title="Output" |
| 183 | +[ |
| 184 | + { |
| 185 | + "enabled": true, |
| 186 | + "frequency": 300, |
| 187 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-webtest-demo/providers/Microsoft.Insights/webtests/my-web-test", |
| 188 | + "kind": "standard", |
| 189 | + "location": "westeurope", |
| 190 | + "locations": [ |
| 191 | + { |
| 192 | + "Id": "us-tx-sn1-azr" |
| 193 | + } |
| 194 | + ], |
| 195 | + "name": "my-web-test", |
| 196 | + "request": { |
| 197 | + "httpVerb": "GET", |
| 198 | + "requestUrl": "https://example.com" |
| 199 | + }, |
| 200 | + "timeout": 30, |
| 201 | + "type": "Microsoft.Insights/webtests", |
| 202 | + "webTestKind": "standard", |
| 203 | + "webTestName": "My Web Test" |
| 204 | + } |
| 205 | +] |
| 206 | +``` |
| 207 | +
|
| 208 | +### Delete a web test |
| 209 | +
|
| 210 | +Delete the web test and verify it no longer appears in the list: |
| 211 | +
|
| 212 | +```bash |
| 213 | +az monitor app-insights web-test delete \ |
| 214 | + --name my-web-test \ |
| 215 | + --resource-group rg-webtest-demo \ |
| 216 | + --yes |
| 217 | +``` |
| 218 | +
|
| 219 | +Then list all web tests to confirm the resource group is now empty: |
| 220 | +
|
| 221 | +```bash |
| 222 | +az monitor app-insights web-test list --resource-group rg-webtest-demo |
| 223 | +``` |
| 224 | +
|
| 225 | +```bash title="Output" |
| 226 | +[] |
| 227 | +``` |
| 228 | +
|
| 229 | +## Features |
| 230 | +
|
| 231 | +- **Web test lifecycle:** Create, read, list, and delete web test resources. |
| 232 | +- **Classic ping and standard test kinds:** Accept `ping`, `multistep`, and `standard` test kinds. |
| 233 | +- **Test location configuration:** Accept one or more agent location IDs per test. |
| 234 | +- **Request configuration:** Define URL, HTTP verb, headers, and body for standard tests. |
| 235 | +- **Frequency and timeout settings:** Configure probing frequency and response timeout. |
| 236 | +- **Application Insights linking:** Associate web tests with an Application Insights component via a `hidden-link` tag on the web test resource (see [Web Tests REST API examples](https://learn.microsoft.com/en-us/rest/api/application-insights/web-tests/create-or-update?view=rest-application-insights-2022-06-15)). |
| 237 | +- **Enable/disable flag:** Enable or disable a web test without deleting it. |
| 238 | +
|
| 239 | +## Limitations |
| 240 | +
|
| 241 | +- **No HTTP probes sent:** LocalStack does not send HTTP requests to the configured URL. |
| 242 | +- **No availability data collected:** Pass, fail, and response time data is not recorded. |
| 243 | +- **No availability alerts fired:** Alert rules associated with a web test are not triggered. |
| 244 | +- **No synthetic transactions:** Multi-step web tests (`multistep` kind), which rely on a recorded XML web test sequence, are not executed; only metadata is emulated locally. |
| 245 | +
|
| 246 | +## Samples |
| 247 | +
|
| 248 | +Explore end-to-end examples in the [LocalStack for Azure Samples](https://github.com/localstack/localstack-azure-samples) repository. |
| 249 | +
|
| 250 | +## API Coverage |
| 251 | +
|
| 252 | +<AzureFeatureCoverage service="Microsoft.Insights" client:load /> |
0 commit comments