Azure / Azure/azure-cli

ScaleCapacity properties should use integer instead of string

Open
#33,750 1 comment 0 reactions 1 assignee Claimed by @isra-fel View on GitHub
Azure CLI Team question
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Related command**

`az deployment group create`

The issue is related to the `Microsoft.Insights/autoscalesettings` ARM/Bicep resource schema used during Azure deployments.

---

**Is your feature request related to a problem? Please describe.**

The `ScaleCapacity` properties (`minimum`, `maximum`, and `default`) are currently defined as `string`, even though they represent numeric instance counts.

For example:

```bicep
capacity: {
minimum: '1'
maximum: '10'
default: '2'
}
```

This feels unintuitive because these properties always represent numbers rather than arbitrary text. As a result, Bicep cannot provide strong type checking, and the schema allows any string value instead of only valid integer values.

---

**Describe the solution you'd like**

It would be preferable for these properties to use an integer type instead of a string type.

For example:

```bicep
capacity: {
minimum: 1
maximum: 10
default: 2
}
```

Using integers would:

- Better reflect the semantic meaning of these properties.
- Improve type safety.
- Provide better validation during authoring.
- Make the resource schema more consistent with other numeric Azure resource properties.

I understand that changing the existing API version may introduce a breaking change. If so, this could be considered for a future API version.

---

**Describe alternatives you've considered**

The current workaround is to explicitly convert integer values using the `string()` function.

For example:

```bicep
param instanceCount int = 2

resource vmss 'Microsoft.Compute/virtualMachineScaleSets@...' = {
sku: {
capacity: instanceCount
}
}

resource autoscale 'Microsoft.Insights/autoscalesettings@...' = {
properties: {
profiles: [
{
capacity: {
minimum: string(instanceCount)
maximum: string(instanceCount)
default: string(instanceCount)
}
}
]
}
}
```

Although `sku.capacity` can be omitted when autoscale manages the instance count, both `VirtualMachineScaleSets.sku.capacity` and `ScaleCapacity` represent the number of VM instances. However, one uses an `int` while the other uses a `string`, resulting in an inconsistent authoring experience and requiring unnecessary type conversions.

---

**Additional context**

Documentation references:

- Autoscale Settings: https://learn.microsoft.com/en-us/azure/templates/microsoft.insights/autoscalesettings?pivots=deployment-language-bicep#scalecapacity
- Virtual Machine Scale Sets: https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachinescalesets?pivots=deployment-language-bicep

The VMSS `sku.capacity` property is defined as an integer, while the Autoscale `ScaleCapacity` properties are defined as strings, despite both representing the number of VM instances.

I'm not sure whether this is a historical design decision or a technical limitation, but aligning these types would make the API more consistent and improve the developer experience.

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.