Azure / Azure/azure-cli

az monitor app-insights web-test create, required parameters not correct and defaults to kind = ping

Open
#29,135 3 comments 0 reactions 1 assignee Claimed by @AllyW View on GitHub
act-observability-squad Auto-Assign Azure CLI Team customer-reported Monitor question
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

The required parameters for the command `az monitor app-insights web-test create` do not appear to be configured and documented correctly.

The required parameters documented at https://learn.microsoft.com/en-us/cli/azure/monitor/app-insights/web-test?view=azure-cli-latest#az-monitor-app-insights-web-test-create, are:

`--name --web-test-name -n`
`--resource-group -g`

However, via trial and error more required parameters seem to be required:
`--tags "hidden-link:/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/microsoft.insights/components/$APP_INSIGHTS_RESOURCE"="Resource"`
`--defined-web-test-name`
`--locations`
`--web-test` or `--web-test-kind` (and dependent associated commands)

Also the `kind` value defaults to `ping`, which is due to be retired and is set even when the `--web-test-kind` parameter is set to `standard`. If an Availability test is created via the Azure Portal, the `kind` value is `null` which can't be overwritten by Azure CLI commands.

Ping and Multistep availability is due to be retired and replaced by standard tests.

### Related command

```
user@ubuntu:~$ az monitor app-insights web-test create \
--subscription "$SUBSCRIPTION_ID" \
--resource-group "$RESOURCE_GROUP" \
--name "availability-test-01-$APP_INSIGHTS_RESOURCE"
(BadRequest) A single 'hidden-link' tag pointing to an existing AI component is required. Found none.
Code: BadRequest
Message: A single 'hidden-link' tag pointing to an existing AI component is required. Found none.
Inner error: {
"trace": [
"System.ArgumentException"
]
}
user@ubuntu:~$ az monitor app-insights web-test create \
--subscription "$SUBSCRIPTION_ID" \
--resource-group "$RESOURCE_GROUP" \
--name "availability-test-01-$APP_INSIGHTS_RESOURCE" \
--tags "hidden-link:/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/microsoft.insights/components/$APP_INSIGHTS_RESOURCE"="Resource"
(BadRequest) Value cannot be null.
Parameter name: 'properties.Name' must be specified
Code: BadRequest
Message: Value cannot be null.
Parameter name: 'properties.Name' must be specified
Inner error: {
"trace": [
"System.ArgumentNullException"
]
}
user@ubuntu:~$ az monitor app-insights web-test create \
--subscription "$SUBSCRIPTION_ID" \
--resource-group "$RESOURCE_GROUP" \
--name "availability-test-01-$APP_INSIGHTS_RESOURCE" \
--tags "hidden-link:/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/microsoft.insights/components/$APP_INSIGHTS_RESOURCE"="Resource" \
--defined-web-test-name "availability-test-01-$APP_INSIGHTS_RESOURCE"
(BadRequest) Value cannot be null.
Parameter name: 'properties.Locations' must be specified
Code: BadRequest
Message: Value cannot be null.
Parameter name: 'properties.Locations' must be specified
Inner error: {
"trace": [
"System.ArgumentNullException"
]
}
user@ubuntu:~$ az monitor app-insights web-test create \
--subscription "$SUBSCRIPTION_ID" \
--resource-group "$RESOURCE_GROUP" \
--name "availability-test-01-$APP_INSIGHTS_RESOURCE" \
--tags "hidden-link:/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/microsoft.insights/components/$APP_INSIGHTS_RESOURCE"="Resource" \
--defined-web-test-name "availability-test-01-$APP_INSIGHTS_RESOURCE" \
--locations "Id"="us-ca-sjc-azr"
(BadRequest) Value cannot be null.
Parameter name: 'properties.Configuration.WebTest' must be specified
Code: BadRequest
Message: Value cannot be null.
Parameter name: 'properties.Configuration.WebTest' must be specified
Inner error: {
"trace": [
"System.ArgumentNullException"
]
}
user@ubuntu:~$ az monitor app-insights web-test create \
--subscription "$SUBSCRIPTION_ID" \
--resource-group "$RESOURCE_GROUP" \
--name "availability-test-01-$APP_INSIGHTS_RESOURCE" \
--tags "hidden-link:/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/microsoft.insights/components/$APP_INSIGHTS_RESOURCE"="Resource" \
--defined-web-test-name "availability-test-01-$APP_INSIGHTS_RESOURCE" \
--locations "Id"="us-ca-sjc-azr" \
--web-test-kind "standard"
(BadRequest) Specified argument was out of the range of valid values.
Parameter name: Error code: PropertyMissingForKind. Web test 'availability-test-01-$APP_INSIGHTS_RESOURCE' is invalid. Required property 'Request' is missing for 'standard' web test
Code: BadRequest
Message: Specified argument was out of the range of valid values.
Parameter name: Error code: PropertyMissingForKind. Web test 'availability-test-01-$APP_INSIGHTS_RESOURCE' is invalid. Required property 'Request' is missing for 'standard' web test
Inner error: {
"trace": [
"System.ArgumentOutOfRangeException"
]
}
user@ubuntu:~$
```

### Errors

See above related commands and the output.

### Issue script & Debug output

Should be easy to replicate.

(note `"kind": "ping"` present in debug logs but not set via the command or required for a `standard` test)

```
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Insights/webtests/availability-test-01-?api-version=2022-06-15'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json'
cli.azure.cli.core.sdk.policies: 'Content-Length': '374'
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': 'd7e06ad7-2716-11ef-bb1e-6bdaffedc136'
cli.azure.cli.core.sdk.policies: 'CommandName': 'monitor app-insights web-test create'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--subscription --resource-group --name --tags --defined-web-test-name --locations --web-test-kind --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.61.0 (DEB) azsdk-python-core/1.28.0 Python/3.11.8 (Linux-6.5.0-35-generic-x86_64-with-glibc2.35)'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"location": "westus2", "tags": {"hidden-link:/subscriptions//resourceGroups//providers/microsoft.insights/components/": "Resource"}, "kind": "ping", "properties": {"Name": "availability-test-01-", "Frequency": 300, "Timeout": 30, "Kind": "standard", "Locations": [{"Id": "us-ca-sjc-azr"}]}}
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions//resourceGroups//providers/Microsoft.Insights/webtests/availability-test-01-?api-version=2022-06-15 HTTP/1.1" 400 409
cli.azure.cli.core.sdk.policies: Response status: 400
```

### Expected behavior

`kind` value either allows `null` or `standard` or is not required in favour of `--web-test-kind`

Documentation corrected to confirm the Required parameters.

### Environment Summary

azure-cli 2.61.0

core 2.61.0
telemetry 1.1.0

Extensions:
account 0.2.5
application-insights 1.2.1
functionapp 0.1.1

Dependencies:
msal 1.28.0
azure-mgmt-resource 23.1.1

Python location '/opt/az/bin/python3'

Python (Linux) 3.11.8 (main, May 16 2024, 03:47:28) [GCC 11.4.0]

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.