Skip to content

[AKS] az aks create: Update prom and logs addon to use sdk#31828

Merged
yanzhudd merged 5 commits intoAzure:devfrom
bragi92:kaveesh/sdk_calls
Jul 24, 2025
Merged

[AKS] az aks create: Update prom and logs addon to use sdk#31828
yanzhudd merged 5 commits intoAzure:devfrom
bragi92:kaveesh/sdk_calls

Conversation

@bragi92
Copy link
Copy Markdown
Member

@bragi92 bragi92 commented Jul 16, 2025

Related command

az aks enable-addons -a monitoring and related Azure Monitor logs addon commands

az aks create/update --enable-azure-monitor-metrics and related Azure Monitor metrics commands

Description
This PR modernizes Azure Monitor metrics and logs addon code by replacing direct HTTP API calls (send_raw_request) with Azure SDK client methods. This improves code maintainability, type safety, and error handling consistency.

Testing Guide
Test the Azure Monitor metrics and logs addon functionality:

# Test enabling Azure Monitor metrics addon
az aks enable-addons --addons monitoring --name <cluster-name> --resource-group <resource-group>
az aks update --resource-group kaveeshcli  --name kaveeshcli --enable-azure-monitor-metrics
az aks update --resource-group kaveeshcli  --name kaveeshcli --disable-azure-monitor-metrics

# Test recording rules operations
az aks show --name <cluster-name> --resource-group <resource-group>

# Test data collection rule operations
# Verify that addon configurations work correctly after the SDK migration

History Notes

This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings July 16, 2025 23:48
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jul 16, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️latest
️✔️3.12
️✔️3.9

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jul 16, 2025

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes Azure Monitor metrics and logs addon code by replacing direct HTTP API calls (send_raw_request) with Azure SDK client methods. This improves code maintainability, type safety, and error handling consistency.

  • Replaces send_raw_request calls with Azure SDK resource client methods (begin_create_or_update_by_id, begin_delete_by_id, etc.)
  • Standardizes exception handling from CLIError to generic Exception with consistent re-raising patterns
  • Converts JSON string bodies to Python dictionaries for SDK compatibility

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
delete.py Replace raw DELETE requests with SDK delete methods for recording rules
create.py Replace raw PUT requests with SDK create/update methods for recording rules
helper.py Replace raw POST request with SDK provider registration
dc/delete.py Replace raw requests with SDK methods for data collection object deletion
dcra_api.py Replace raw PUT request with SDK method for data collection rule association
dcr_api.py Replace raw PUT request with SDK method for data collection rule creation
dce_api.py Replace raw PUT request with SDK method for data collection endpoint creation
amw/create.py Replace raw PUT request with SDK method for Azure Monitor Workspace creation
amg/link.py Replace raw requests with SDK methods for Grafana instance linking
addonput.py Replace raw GET/PUT requests with managed cluster client methods
addonconfiguration.py Replace multiple raw requests with SDK methods for container insights configuration

Comment thread src/azure-cli/azure/cli/command_modules/acs/addonconfiguration.py
Comment thread src/azure-cli/azure/cli/command_modules/acs/azuremonitormetrics/amg/link.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/acs/azuremonitormetrics/amg/link.py Outdated
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Jul 16, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@FumingZhang
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

bragi92 and others added 4 commits July 17, 2025 13:12
@bragi92 bragi92 changed the title fix: update prom and logs addon to use sdk [AKS] fix: update prom and logs addon to use sdk Jul 17, 2025
@bragi92 bragi92 changed the title [AKS] fix: update prom and logs addon to use sdk [AKS] az aks create: Update prom and logs addon to use sdk Jul 17, 2025
@FumingZhang
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@bragi92 bragi92 changed the title [AKS] az aks create: Update prom and logs addon to use sdk [AKS] az aks create: Update prom and logs addon to use sdk Jul 18, 2025
@bragi92
Copy link
Copy Markdown
Member Author

bragi92 commented Jul 18, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 31828 in repo Azure/azure-cli

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Jul 19, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Member

@FumingZhang FumingZhang left a comment

Choose a reason for hiding this comment

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

Queued live test to validate the change, one of 10 failed, re-queued test_aks_update_with_azuremonitormetrics, test passed!

  • test_aks_create_with_azuremonitormetrics
  • test_aks_update_with_azuremonitormetrics
  • test_aks_create_with_monitoring_aad_auth_msi
  • test_aks_create_with_monitoring_aad_auth_msi_with_syslog
  • test_aks_create_with_monitoring_aad_auth_msi_with_datacollectionsettings
  • test_aks_create_with_monitoring_aad_auth_msi_with_datacollectionsettings_and_otheraddon
  • test_aks_create_with_private_cluster_with_monitoring_aad_auth_msi_with_ampls
  • test_aks_create_with_monitoring_aad_auth_with_highlogscale
  • test_aks_enable_monitoring_with_aad_auth_uai_with_syslog
  • test_aks_enable_monitoring_with_aad_auth_uai

@yanzhudd yanzhudd merged commit 931a450 into Azure:dev Jul 24, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants