Skip to content

{AKS} az aks alert-config: Add commands to manage alert configurations - #10155

Open
Matheus Mortatti (mamortat) wants to merge 6 commits into
Azure:mainfrom
mamortat:feat/aks-alert-config-pr
Open

{AKS} az aks alert-config: Add commands to manage alert configurations#10155
Matheus Mortatti (mamortat) wants to merge 6 commits into
Azure:mainfrom
mamortat:feat/aks-alert-config-pr

Conversation

@mamortat

@mamortat Matheus Mortatti (mamortat) commented Jul 28, 2026

Copy link
Copy Markdown

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes
⚠️ None
⚠️Azure CLI Extensions Breaking Change Test
⚠️aks-preview
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd aks alert-config sub group aks alert-config added

Ready for review: the RP contract issue is resolved and the command flow was verified
live in eastus2euap against API version 2026-05-02-preview.

The recording toolchain now works locally through Microsoft's internal package proxy, without
accessing public PyPI. The recording run currently reaches alert-config add but the RP
operation fails with ListLoadBalancerError / InvalidAuthenticationTokenTenant while looking
up the cluster's managed resource group. The end-to-end scenario remains @live_only() until
that RP-side cross-tenant token issue is resolved.

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|list

Description

Adds 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
(spec: Azure/azure-rest-api-specs#44598).

The vendored SDK already ships AlertConfigurationsOperations as of #10143, so this PR is
purely the command surface.

az aks alert-config add    -g RG --cluster-name C -n NAME --mode Managed|Disabled \
                           [--action-group-id ID] [--no-wait]
az aks alert-config update -g RG --cluster-name C -n NAME [--mode ...] \
                           [--action-group-id ID] [--no-wait]
az aks alert-config delete -g RG --cluster-name C -n NAME [--yes] [--no-wait]
az aks alert-config show   -g RG --cluster-name C -n NAME
az aks alert-config list   -g RG --cluster-name C

Implementation follows the existing az aks jwtauthenticator pattern.

Design notes

The resource has two writable properties, mode and notification.actionGroupId. Per the
swagger, properties.required = [mode, notification] and
AlertNotification.required = [actionGroupId].

  • --action-group-id is optional. The notification object is always emitted, with
    actionGroupId set to the supplied value or "", so the required key is never absent.
    The RP accepts an empty value.
  • update performs a read-modify-write. The API is PUT-only and both properties are
    required, so update GETs the existing configuration and merges, letting callers change
    one property at a time. An omitted --action-group-id preserves the current value; an
    explicit --action-group-id "" clears it.
  • update on a missing configuration raises ResourceNotFoundError pointing at
    az aks alert-config add rather than silently creating one.
  • --action-group-id is validated client-side to be a
    Microsoft.Insights/actionGroups resource ID before any network call.

Validation

  • azdev style aks-preview
  • azdev linter --include-whl-extensions aks-preview
  • python scripts/ci/test_index.py -q
  • Required PR checks across supported Python versions
  • Live add/show/list/update/delete flow in eastus2euap

The test suite includes 279 passing unit tests, including 25 new tests in
test_alert_configuration.py. The command table, argument registry, validators, serialized
request bodies, read-modify-write behavior, and action-group clearing behavior are covered.

Replay-test limitation

test_aks_alert_config_cmds exercises add → show → list → update → delete and is pinned to
eastus2euap with preserve_default_location=True.

The original response-contract issue is fixed: create returns 201, update returns 200,
and both responses match the vendored SDK contract. The local toolchain was successfully
created using https://packagefeedproxy.microsoft.io/pypi/simple/; all 25 targeted unit
tests pass and the scenario enters recording mode.

The current blocker is in the RP operation itself. After the cluster reaches Succeeded,
alert-config add fails because the RP attempts the managed-resource-group lookup with a
token issued by a different tenant than the subscription. Until that service-side issue is
resolved, the scenario is explicitly @live_only() and the unit-test coverage remains the
CI safety net.

Per the guidance block at the top of HISTORY.rst, this PR adds an entry under Pending
without bumping VERSION in setup.py.

Copilot AI review requested due to automatic review settings July 28, 2026 19:44
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi Matheus Mortatti (@mamortat),
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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|list commands wired to the vendored AlertConfigurationsOperations.
  • Adds --action-group-id validation 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).

Comment on lines +25242 to +25246
@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(
random_name_length=17, name_prefix="clitest", location="eastus"
)
def test_aks_alert_config_cmds(self, resource_group, resource_group_location):
Comment on lines +86 to +89
merged_mode = mode if mode is not None else existing_mode
merged_action_group_id = (
action_group_id if action_group_id is not None else existing_action_group_id
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

Comment on lines +86 to +89
merged_mode = mode if mode is not None else existing_mode
merged_action_group_id = (
action_group_id if action_group_id is not None else existing_action_group_id
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# recorded yet. A recording-based test will replace this once the feature is enabled more
# broadly.
@live_only()
def test_aks_alert_config_cmds(self, resource_group, resource_group_location):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide proof that the test could pass in a dedicated sub? Or you may re-queue this live test pipeline with pipeline variables set to your sub.
https://dev.azure.com/msazure/CloudNativeCompute/_build/results?buildId=174242178&view=results

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to merge a fix on the RP before being able to do it, but now I'm having issues recording the tests due to the pypi block we have now. I'm working on it

Matheus Mortatti and others added 4 commits July 29, 2026 12:09
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>
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@mamortat
Matheus Mortatti (mamortat) marked this pull request as draft July 29, 2026 19:20
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>
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@mamortat
Matheus Mortatti (mamortat) marked this pull request as ready for review August 6, 2026 22:21
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
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>
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants