You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The monitor module ships a vendored copy of the pre-refactor code in `_legacy/`. Users can switch to this snapshot via config if the refactored implementation causes issues:
6
+
7
+
```bash
8
+
az config set monitor.use_legacy=true # enable legacy mode
9
+
az config set monitor.use_legacy=false # switch back to new mode (default)
10
+
```
11
+
12
+
A warning is logged each time legacy mode is active.
13
+
14
+
## How It Works
15
+
16
+
In `__init__.py`, `MonitorCommandsLoader` reads the `monitor.use_legacy` config (default `false`):
17
+
18
+
-**New mode** — loads from `aaz/`, `operations/`, and `commands.py` using `load_aaz_command_table_args_guided`.
19
+
-**Legacy mode** — loads from `_legacy/aaz/`, `_legacy/commands.py` using `load_aaz_command_table`. Arguments come from `_legacy/_params.py`.
20
+
21
+
The `_legacy/` folder is a frozen snapshot extracted from the `dev` branch. All absolute imports were rewritten from `azure.cli.command_modules.monitor.` to `azure.cli.command_modules.monitor._legacy.`.
22
+
23
+
## Known Adjustments
24
+
25
+
-**`_legacy/_params.py`**: Removed `monitor metrics alert update` argument registrations (lines for `add_actions`, `remove_actions`, `add_conditions`, `remove_conditions`) because the AAZ `MetricsAlertUpdate._build_arguments_schema` already defines them, and the old-style `action=MetricAlertAddAction` overrides corrupt AAZ argument parsing.
26
+
-**Tests**: `test_monitor_general_operations.py` mocks `gen_guid` at both `azure.cli.command_modules.monitor.operations.monitor_clone_util` and `azure.cli.command_modules.monitor._legacy.operations.monitor_clone_util` so tests pass in either mode.
27
+
-**Linting**: `_legacy/` is excluded via `pylintrc` (`ignore` list) and `.flake8` (`exclude` list).
2.**Simplify `__init__.py`** — remove `_use_legacy`, `_load_legacy_command_table`, and the dispatch in `load_command_table` / `load_arguments`. Inline `_load_new_command_table` as the sole `load_command_table`:
39
+
```python
40
+
# Remove these
41
+
_CONFIG_SECTION='monitor'
42
+
_USE_LEGACY_CONFIG_KEY='use_legacy'
43
+
self._use_legacy =...
44
+
def_load_legacy_command_table(self, args): ...
45
+
46
+
# Keep only _load_new_command_table logic directly in load_command_table
47
+
```
48
+
49
+
3.**Clean up tests** — remove the second `mock.patch` line for `_legacy` in `test_monitor_general_operations.py`:
0 commit comments