Skip to content

Conversation

@tokaplan
Copy link

{AKS} Add support for Azure Monitor Application Monitoring auto-instrumentation

Related command

az aks update -g resourceGroup1 -n cluster1 --enable-azure-monitor-app-monitoring

Description
We are GAing the --enable-azure-monitor-app-monitoring and --disable-azure-monitor-app-monitoring CLI flags that control the appMonitoring field of the Azure Monitor Unified Profile in AKS Managed Cluster profile: link to API review

Testing Guide
Create a cluster with auto-instrumentation enabled:

az aks create -g alkaplan1 -n cluster1 --enable-azure-monitor-app-monitoring

Enable auto-instrumentation for a cluster:

az aks update -g alkaplan1 -n cluster1 --enable-azure-monitor-app-monitoring

Disable auto-instrumentation for a cluster:

az aks update -g alkaplan1 -n cluster1 --disable-azure-monitor-app-monitoring

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

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

azure-client-tools-bot-prd bot commented Jan 27, 2026

❌AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
❌acs
❌latest
❌3.12
Type Test Case Error Message Line
Failed test_update_azure_monitor_profile_disable_app_monitoring self = <azure.cli.command_modules.acs.tests.latest.test_managed_cluster_decorator.AKSManagedClusterUpdateDecoratorTestCase testMethod=test_update_azure_monitor_profile_disable_app_monitoring>

    def test_update_azure_monitor_profile_disable_app_monitoring(self):
        # Test disabling app monitoring on a cluster with existing azure_monitor_profile
        dec_1 = AKSManagedClusterUpdateDecorator(
            self.cmd,
            self.client,
            {
                "disable_azure_monitor_app_monitoring": True,
            },
            ResourceType.MGMT_CONTAINERSERVICE,
        )
        mc_1 = self.models.ManagedCluster(
            location="test_location",
            azure_monitor_profile=self.models.ManagedClusterAzureMonitorProfile(
>               app_monitoring=self.models.ManagedClusterAzureMonitorProfileAppMonitoring(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    auto_instrumentation=self.models.ManagedClusterAzureMonitorProfileAppMonitoringAutoInstrumentation(
                        enabled=True
                    )
                )
            )
        )
E       AttributeError: 'AKSManagedClusterModels' object has no attribute 'ManagedClusterAzureMonitorProfileAppMonitoring'

src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py:14265: AttributeError
azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py:14251
Failed test_update_azure_monitor_profile_enable_app_monitoring self = <azure.cli.command_modules.acs.tests.latest.test_managed_cluster_decorator.AKSManagedClusterUpdateDecoratorTestCase testMethod=test_update_azure_monitor_profile_enable_app_monitoring>

    def test_update_azure_monitor_profile_enable_app_monitoring(self):
        # Test enabling app monitoring on a cluster without existing azure_monitor_profile
        dec_1 = AKSManagedClusterUpdateDecorator(
            self.cmd,
            self.client,
            {
                "enable_azure_monitor_app_monitoring": True,
            },
            ResourceType.MGMT_CONTAINERSERVICE,
        )
        mc_1 = self.models.ManagedCluster(location="test_location")
        dec_1.context.attach_mc(mc_1)
>       dec_mc_1 = dec_1.update_azure_monitor_profile(mc_1)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py:14245: 
                                        

self = <azure.cli.command_modules.acs.managed_cluster_decorator.AKSManagedClusterUpdateDecorator object at 0x7efecd1a9dc0>
mc = <azure.mgmt.containerservice.models._models_py3.ManagedCluster object at 0x7efecd104740>

    def update_azure_monitor_profile(self, mc: ManagedCluster) -> ManagedCluster:
        """Update azure monitor profile for the ManagedCluster object.
        :return: the ManagedCluster object
        """
        self._ensure_mc(mc)
    
        # read the original value passed by the command
        ksm_metric_labels_allow_list = self.context.raw_param.get("ksm_metric_labels_allow_list")
        ksm_metric_annotations_allow_list = self.context.raw_param.get("ksm_metric_annotations_allow_list")
    
        if ksm_metric_labels_allow_list is None:
            ksm_metric_labels_allow_list = ""
        if ksm_metric_annotations_allow_list is None:
            ksm_metric_annotations_allow_list = ""
    
        if self.context.get_enable_azure_monitor_metrics():
            if mc.azure_monitor_profile is None:
                mc.azure_monitor_profile = self.models.ManagedClusterAzureMonitorProfile()
            mc.azure_monitor_profile.metrics = self.models.ManagedClusterAzureMonitorProfileMetrics(enabled=True)
            mc.azure_monitor_profile.metrics.kube_state_metrics = self.models.ManagedClusterAzureMonitorProfileKubeStateMetrics(  # pylint:disable=line-too-long
                metric_labels_allowlist=str(ksm_metric_labels_allow_list),
                metric_annotations_allow_list=str(ksm_metric_annotations_allow_list))
    
        if self.context.get_disable_azure_monitor_metrics():
            if mc.azure_monitor_profile is None:
                mc.azure_monitor_profile = self.models.ManagedClusterAzureMonitorProfile()
            mc.azure_monitor_profile.metrics = self.models.ManagedClusterAzureMonitorProfileMetrics(enabled=False)
    
        if (
            self.context.raw_param.get("enable_azure_monitor_metrics") or
            self.context.raw_param.get("disable_azure_monitor_metrics")
        ):
            self.context.external_functions.ensure_azure_monitor_profile_prerequisites(
                self.cmd,
                self.context.get_subscription_id(),
                self.context.get_resource_group_name(),
                self.context.get_name(),
                self.context.get_location(),
                self.__raw_parameters,
                self.context.get_disable_azure_monitor_metrics(),
                False)
    
    
        if self.context.get_enable_azure_monitor_app_monitoring():
            if mc.azure_monitor_profile is None:
                mc.azure_monitor_profile = self.models.ManagedClusterAzureMonitorProfile()
>           if mc.azure_monitor_profile.app_monitoring is None:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E           AttributeError: 'ManagedClusterAzureMonitorProfile' object has no attribute 'app_monitoring'

src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py:8985: AttributeError
azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py:14232
❌3.13
Type Test Case Error Message Line
Failed test_update_azure_monitor_profile_disable_app_monitoring self = <azure.cli.command_modules.acs.tests.latest.test_managed_cluster_decorator.AKSManagedClusterUpdateDecoratorTestCase testMethod=test_update_azure_monitor_profile_disable_app_monitoring>

    def test_update_azure_monitor_profile_disable_app_monitoring(self):
        # Test disabling app monitoring on a cluster with existing azure_monitor_profile
        dec_1 = AKSManagedClusterUpdateDecorator(
            self.cmd,
            self.client,
            {
                "disable_azure_monitor_app_monitoring": True,
            },
            ResourceType.MGMT_CONTAINERSERVICE,
        )
        mc_1 = self.models.ManagedCluster(
            location="test_location",
            azure_monitor_profile=self.models.ManagedClusterAzureMonitorProfile(
>               app_monitoring=self.models.ManagedClusterAzureMonitorProfileAppMonitoring(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    auto_instrumentation=self.models.ManagedClusterAzureMonitorProfileAppMonitoringAutoInstrumentation(
                        enabled=True
                    )
                )
            )
        )
E       AttributeError: 'AKSManagedClusterModels' object has no attribute 'ManagedClusterAzureMonitorProfileAppMonitoring'. Did you mean: 'ManagedClusterAzureMonitorProfileMetrics'?

src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py:14265: AttributeError
azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py:14251
Failed test_update_azure_monitor_profile_enable_app_monitoring self = <azure.cli.command_modules.acs.tests.latest.test_managed_cluster_decorator.AKSManagedClusterUpdateDecoratorTestCase testMethod=test_update_azure_monitor_profile_enable_app_monitoring>

    def test_update_azure_monitor_profile_enable_app_monitoring(self):
        # Test enabling app monitoring on a cluster without existing azure_monitor_profile
        dec_1 = AKSManagedClusterUpdateDecorator(
            self.cmd,
            self.client,
            {
                "enable_azure_monitor_app_monitoring": True,
            },
            ResourceType.MGMT_CONTAINERSERVICE,
        )
        mc_1 = self.models.ManagedCluster(location="test_location")
        dec_1.context.attach_mc(mc_1)
>       dec_mc_1 = dec_1.update_azure_monitor_profile(mc_1)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py:14245: 
                                        

self = <azure.cli.command_modules.acs.managed_cluster_decorator.AKSManagedClusterUpdateDecorator object at 0x7f3adf851550>
mc = <azure.mgmt.containerservice.models._models_py3.ManagedCluster object at 0x7f3adf851e80>

    def update_azure_monitor_profile(self, mc: ManagedCluster) -> ManagedCluster:
        """Update azure monitor profile for the ManagedCluster object.
        :return: the ManagedCluster object
        """
        self._ensure_mc(mc)
    
        # read the original value passed by the command
        ksm_metric_labels_allow_list = self.context.raw_param.get("ksm_metric_labels_allow_list")
        ksm_metric_annotations_allow_list = self.context.raw_param.get("ksm_metric_annotations_allow_list")
    
        if ksm_metric_labels_allow_list is None:
            ksm_metric_labels_allow_list = ""
        if ksm_metric_annotations_allow_list is None:
            ksm_metric_annotations_allow_list = ""
    
        if self.context.get_enable_azure_monitor_metrics():
            if mc.azure_monitor_profile is None:
                mc.azure_monitor_profile = self.models.ManagedClusterAzureMonitorProfile()
            mc.azure_monitor_profile.metrics = self.models.ManagedClusterAzureMonitorProfileMetrics(enabled=True)
            mc.azure_monitor_profile.metrics.kube_state_metrics = self.models.ManagedClusterAzureMonitorProfileKubeStateMetrics(  # pylint:disable=line-too-long
                metric_labels_allowlist=str(ksm_metric_labels_allow_list),
                metric_annotations_allow_list=str(ksm_metric_annotations_allow_list))
    
        if self.context.get_disable_azure_monitor_metrics():
            if mc.azure_monitor_profile is None:
                mc.azure_monitor_profile = self.models.ManagedClusterAzureMonitorProfile()
            mc.azure_monitor_profile.metrics = self.models.ManagedClusterAzureMonitorProfileMetrics(enabled=False)
    
        if (
            self.context.raw_param.get("enable_azure_monitor_metrics") or
            self.context.raw_param.get("disable_azure_monitor_metrics")
        ):
            self.context.external_functions.ensure_azure_monitor_profile_prerequisites(
                self.cmd,
                self.context.get_subscription_id(),
                self.context.get_resource_group_name(),
                self.context.get_name(),
                self.context.get_location(),
                self.__raw_parameters,
                self.context.get_disable_azure_monitor_metrics(),
                False)
    
    
        if self.context.get_enable_azure_monitor_app_monitoring():
            if mc.azure_monitor_profile is None:
                mc.azure_monitor_profile = self.models.ManagedClusterAzureMonitorProfile()
>           if mc.azure_monitor_profile.app_monitoring is None:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E           AttributeError: 'ManagedClusterAzureMonitorProfile' object has no attribute 'app_monitoring'

src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py:8985: AttributeError
azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py:14232
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

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

azure-client-tools-bot-prd bot commented Jan 27, 2026

⚠️AzureCLI-BreakingChangeTest
⚠️acs
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd aks create cmd aks create added parameter enable_azure_monitor_app_monitoring
⚠️ 1006 - ParaAdd aks update cmd aks update added parameter disable_azure_monitor_app_monitoring
⚠️ 1006 - ParaAdd aks update cmd aks update added parameter enable_azure_monitor_app_monitoring

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 27, 2026

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

@github-actions
Copy link

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
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

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

Labels

AKS az aks/acs/openshift Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants