Description
The RecurrentSchedule
class in the Azure Monitor Autoscale SDK accepts a List[int]
for the minutes
parameter, as per the documentation:
RecurrentSchedule(*, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs: Any)
However, when passing more than one value (e.g., list(range(60))), the following error is raised not during instantiation, but when calling:
MonitorManagementClient.autoscale_settings.create_or_update(...)
Error message:
Code: BadRequest
Message: The autoscale setting that you provided has an invalid recurrence schedule with invalid count for minutes specified. Specify only one value for minutes.
Expected behavior
Either:
The API should support multiple minute values as the type suggests (List[int]), or
The SDK and documentation should clarify that only one minute value is allowed per recurrence schedule, and enforce this constraint earlier.
The following code should be able to reproduce the bug
from azure.mgmt.monitor import MonitorManagementClient
from azure.mgmt.monitor.models import AutoscaleSettingResource, AutoscaleProfile, Recurrence, RecurrentSchedule, ScaleCapacity
# Assume monitor_client is an authenticated MonitorManagementClient
recurrence = Recurrence(
frequency="Week",
schedule=RecurrentSchedule(
time_zone="UTC",
days=["Monday"],
hours=[0],
minutes=list(range(60)) # This causes the BadRequest error
)
)
profile = AutoscaleProfile(
name="test-profile",
capacity=ScaleCapacity(minimum="1", maximum="3", default="2"),
rules=[], # Simplified for reproduction
recurrence=recurrence
)
autoscale_setting = AutoscaleSettingResource(
location="westeurope",
enabled=True,
target_resource_uri="/subscriptions/.../resourceGroups/.../providers/Microsoft.MachineLearningServices/workspaces/.../onlineEndpoints/...",
profiles=[profile]
)
# This call fails
monitor_client.autoscale_settings.create_or_update(
resource_group_name="my-resource-group",
autoscale_setting_name="test-autoscale-setting",
parameters=autoscale_setting
)