az monitor autoscale rule create bugs and missing config fields
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
### Overview
3 Issues Discovered.
1. **Autoscale direction when using 'to'**
https://github.com/Azure/azure-cli/blob/1fec5c4e721d2313e91c15a5ba542025759131d6/src/azure-cli/azure/cli/command_modules/monitor/util.py#L53
When you use --scale to X in az monitor autoscale rule create it sets the direction to None. This breaks the autoscale rule.
FYI - when creating the same 'to X' rule in the portal this populates the direction correctly with either an 'Increase' or 'Decrease' depending on the other rules in the profile.

2. **dividePerInstance option and parameter is missing**
Additionally, the dividePerInstance field is missing from the autoscale rule cli template as seen here and is a critical missing component (it just seems to get defaulted to true at the moment which breaks my scaling rule needs!). This is populated and available when creating a rule in the portal:

https://github.com/Azure/azure-cli/blob/1fec5c4e721d2313e91c15a5ba542025759131d6/src/azure-cli/azure/cli/command_modules/monitor/operations/autoscale-parameters-template.json#L15
**These are both broken/missing features.**
[Referencing this previous issue:]
#https://github.com/Azure/azure-cli/issues/16027#issue-749669485
**_EDIT_** Found another issue
3. 'az monitor autoscale create' is not idempotent and will wipe all the existing profiles and rules if run again. This kind of makes it a bit useless to be honest as it would wipe profiles and other rules for the autoscale setting in other deployments each time. A check for if it already exists needs to be implemented to make it more in line with the other az commands and patterns.
Contributor guide
Assessment
This issue has not been assessed yet.