Azure / Azure/azure-rest-api-specs

[BUG] Microsoft.Insights Autoscale rules `metricName` require an enum for valid values.

Open
#39,072 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
3d 2h
Merged PRs (30d)
424

Description

### API Spec link

https://github.com/Azure/azure-rest-api-specs/blob/main/specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/autoscale_API.json

### API Spec version

2022-10-01

### Describe the bug

`MetricTrigger.MetricName` should be an enum with valid values instead of a primitive `string` type.

### Expected behavior

This creates ambiguous errors in Azure-powershell which is generated from the spec of azure-rest-api-specs.

See issue: https://github.com/Azure/azure-powershell/issues/24727

### Actual behavior

See issue: https://github.com/Azure/azure-powershell/issues/24727

User receives generic error for the metric name, with no guidance as to what are the accepted values.

### Reproduction Steps

Api call to:

```
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroup}/providers/Microsoft.Insights/autoscalesettings/test-autoscale?api-version=2022-10-01
```

With payload:

```
{
"properties": {
"profiles": [{
"rules": [{
"metricTrigger": {
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.web/serverfarms",
"metricResourceUri": "/subscriptions/.../providers/Microsoft.Web/serverfarms/test-asp"
}
}]
}]
}
}
```

Produces generic error:

```
Error: resource: /subscriptions/.../providers/Microsoft.Web/serverfarms/test-asp,
metricnamespace: microsoft.web/serverfarms,
metricname: Percentage CPU
```

### Environment

Name Value
---- -----
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Contributor guide

Open the contributing guide

Research direction

Open specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/autoscale_API.json and inspect the MetricTrigger.MetricName definition. Compare the metric names accepted by the autoscale API, then update the specification so the field exposes those valid values as an enum. Validate that the specification remains consistent with the referenced 2022-10-01 API behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.