{AKS} az aks alert-config: Add commands to manage alert configurations - #10155
{AKS} az aks alert-config: Add commands to manage alert configurations#10155Matheus Mortatti (mamortat) wants to merge 10 commits into
az aks alert-config: Add commands to manage alert configurations#10155Conversation
|
Hi Matheus Mortatti (@mamortat), |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Adds a new az aks alert-config command group to the aks-preview extension to manage the AKS alertConfigurations child resource (API version 2026-05-02-preview), including client-side validation, table output formatting, and tests.
Changes:
- Introduces
az aks alert-config add|update|delete|show|listcommands wired to the vendoredAlertConfigurationsOperations. - Adds
--action-group-idvalidation and table transformers for list/show output. - Adds unit tests for validators/formatting/internal request shaping and a scenario test covering add→show→list→update→delete.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/aks-preview/HISTORY.rst | Adds a Pending changelog entry for the new command group. |
| src/aks-preview/azext_aks_preview/alertconfiguration.py | Implements internal add/update helpers that construct the SDK models and perform PUT semantics. |
| src/aks-preview/azext_aks_preview/_client_factory.py | Adds a client factory for alert_configurations. |
| src/aks-preview/azext_aks_preview/commands.py | Registers the new aks alert-config command group and hooks up custom commands + table transformers. |
| src/aks-preview/azext_aks_preview/custom.py | Adds custom wrappers for alert-config add/update/delete/show/list. |
| src/aks-preview/azext_aks_preview/_params.py | Registers arguments for aks alert-config including enum --mode and validator for --action-group-id. |
| src/aks-preview/azext_aks_preview/_validators.py | Adds validate_action_group_id to enforce Microsoft.Insights/actionGroups resource IDs. |
| src/aks-preview/azext_aks_preview/_format.py | Adds table transformers for alert-config show/list. |
| src/aks-preview/azext_aks_preview/_help.py | Adds help text and examples for the new command group and commands. |
| src/aks-preview/azext_aks_preview/tests/latest/test_alert_configuration.py | Adds unit tests for validator behavior, table formatting tolerance, and add/update internal request construction. |
| src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py | Adds a scenario test for the new commands (live/recorded test flow). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Add the `az aks alert-config` command group to the aks-preview extension, exposing the alertConfigurations child resource introduced in API version 2026-05-02-preview. Commands: az aks alert-config add/update/delete/show/list The resource has two writable properties, mode (Managed|Disabled) and notification.actionGroupId. Since the API is PUT-only and both properties are required, `update` performs a read-modify-write so callers can change one property at a time. `--action-group-id` is optional and always emitted (as an empty string when unset) to satisfy the required-key contract; an explicit empty string clears it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The alertConfigurations RP endpoint is only deployed to selected regions. Pin the scenario test to eastus2euap and set preserve_default_location so AZURE_CLI_TEST_DEV_RESOURCE_GROUP_LOCATION cannot silently redirect the recording run to a region that rejects the requests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The AlertConfigurationPreview AFEC feature flag must be registered on the test subscription and the RP-side toggle must be active. Both are limited to eastus2euap/centraluseuap on allow-listed subscriptions today, so the scenario cannot be recorded yet. Without a cassette the test would evaluate in_recording as true and attempt a live run in CI, so mark it live_only until the feature is enabled more broadly and a recording can be added. This matches the existing treatment of test_aks_create_and_update_with_managed_nat_gateway_v2. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A live run with the AlertConfigurationPreview flag registered got past the feature gate but failed on the create call: the RP returns 202 for PUT alertConfigurations, while the swagger declares only 200/201 for that operation. The generated SDK therefore treats the 202 as an error and fails deserializing the empty body. Record the blocker in the live_only comment so the marker can be removed once the spec and RP agree and the SDK is re-vendored. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
9381744 to
a308491
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
The RP contract issue is resolved: PUT alertConfigurations now returns 201 on create and 200 on update, both with the resource body and the Azure-AsyncOperation header, verified live in eastus2euap against api-version 2026-05-02-preview. The scenario test still has no cassette, so it stays live_only to avoid attempting a live run in CI. Update the comment so it reflects the actual remaining blocker rather than the now-fixed status code mismatch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Document that the recording toolchain works through the internal package proxy and that the remaining blocker is the RP cross-tenant token failure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Live test results —
|
There was a problem hiding this comment.
Automated Review Summary
PR: {AKS} az aks alert-config: Add commands to manage alert configurations
- ✅ CI checks: 28/28 completed checks passed, 0 failed, 0 pending.
- ✅ Live test: dispatched live-test workflow run completed with
successconclusion.
No issues found. This PR looks ready from an automated-validation standpoint.
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Record the alert configuration CRUD scenario against the eastus2euap canary and enable offline replay. Use Disabled mode while Managed alert materialization is blocked by the RP metric-name mismatch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Describe why the replay scenario uses Disabled mode without implying that replay coverage is missing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
| def _get_alert_config_table_row(result): | ||
| """Extract information from an alert configuration for table display.""" | ||
| properties = result.get('properties') or {} | ||
| notification = properties.get('notification') or {} | ||
| return OrderedDict([ | ||
| ('name', result.get('name', '')), | ||
| ('mode', properties.get('mode', '')), | ||
| ('actionGroupId', notification.get('actionGroupId', '')), | ||
| ('provisioningState', properties.get('provisioningState', '')), | ||
| ]) |
FumingZhang
left a comment
There was a problem hiding this comment.
Please fix the failing CI checks. The default API version has been updated to 2026-06-02-preview, so you’ll need to either re-record the test case or replace all occurrences of 2026-05-02-preview with 2026-06-02-preview in the existing recording file.
| 21.0.0b12 | ||
| ++++++++ | ||
| * Add `--allowed-subjects-from-file` to `az aks identity-binding create` and add a new `az aks identity-binding update` command to manage the `allowedSubjects` list on identity bindings. | ||
| * Add `az aks alert-config` commands to manage AKS-managed alert configurations. |
There was a problem hiding this comment.
please choose a new version number or move your notes to the Pending section
🤖 PR Validation —⚠️ Review suggested
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
az aks alert-config add|update|delete|show|listDescription
Adds the
az aks alert-configcommand group to theaks-previewextension, exposing thealertConfigurationschild resource introduced in API version2026-05-02-preview(spec: Azure/azure-rest-api-specs#44598).
The vendored SDK already ships
AlertConfigurationsOperationsas of #10143, so this PR ispurely the command surface.
Implementation follows the existing
az aks jwtauthenticatorpattern.Design notes
The resource has two writable properties,
modeandnotification.actionGroupId. Per theswagger,
properties.required = [mode, notification]andAlertNotification.required = [actionGroupId].--action-group-idis optional. Thenotificationobject is always emitted, withactionGroupIdset to the supplied value or"", so the required key is never absent.The RP accepts an empty value.
updateperforms a read-modify-write. The API is PUT-only and both properties arerequired, so
updateGETs the existing configuration and merges, letting callers changeone property at a time. An omitted
--action-group-idpreserves the current value; anexplicit
--action-group-id ""clears it.updateon a missing configuration raisesResourceNotFoundErrorpointing ataz aks alert-config addrather than silently creating one.--action-group-idis validated client-side to be aMicrosoft.Insights/actionGroupsresource ID before any network call.Validation
azdev style aks-previewazdev linter --include-whl-extensions aks-previewpython scripts/ci/test_index.py -qeastus2euaptest_aks_alert_config_cmdsThe targeted suite passes 26 tests: the replay scenario plus 25 tests in
test_alert_configuration.py. The command table, argument registry, validators, serializedrequest bodies, read-modify-write behavior, action-group clearing behavior, and complete CRUD
replay flow are covered.
Replay-test coverage
test_aks_alert_config_cmdsexercises add → show → list → update → delete and is pinned toeastus2euapwithpreserve_default_location=True. The cassette is committed and the test nolonger uses
@live_only().The alert-config operations are routed to the
eastus2euapcanary with the AKS Early Birdheader, where the subscription-tenant selection fix is deployed. The scenario records
Disabledmode, including clearing only the action group while preserving the mode throughthe read-modify-write update path.
Managed mode is not part of the cassette yet because the RP alert definition requests
etcd_database_used_size_percentage, while Azure Monitor publishesetcd_database_usage_percentage. The unit tests continue to cover Managed-mode requestserialization independently of that service-side issue.
Per the guidance block at the top of
HISTORY.rst, this PR adds an entry underPendingwithout bumping
VERSIONinsetup.py.