@@ -5720,6 +5720,11 @@ def update_monitoring_profile_flow_logs(self, mc: ManagedCluster) -> ManagedClus
57205720 """
57215721 self ._ensure_mc (mc )
57225722
5723+ # Call the base class implementation if it exists (CLI >= 2.84.0 added this method to the base).
5724+ # This ensures any base-class monitoring handling (e.g., enable/disable) is applied first.
5725+ if hasattr (super (), 'update_monitoring_profile_flow_logs' ):
5726+ mc = super ().update_monitoring_profile_flow_logs (mc )
5727+
57235728 # Trigger validation for high log scale mode when container network logs are enabled.
57245729 # This ensures proper error messages are raised before cluster update if the user
57255730 # explicitly disables high log scale mode while enabling container network logs.
@@ -5756,35 +5761,45 @@ def update_monitoring_profile_flow_logs(self, mc: ManagedCluster) -> ManagedClus
57565761 # monitoring with MSI auth is already enabled, then trigger the DCR update via postprocessing.
57575762 enable_high_log_scale_mode = self .context .raw_param .get ("enable_high_log_scale_mode" )
57585763 if enable_high_log_scale_mode is True :
5759- addon_consts = self .context .get_addon_consts ()
5760- CONST_MONITORING_ADDON_NAME = addon_consts .get ("CONST_MONITORING_ADDON_NAME" )
5761- CONST_MONITORING_USING_AAD_MSI_AUTH = addon_consts .get ("CONST_MONITORING_USING_AAD_MSI_AUTH" )
5764+ # Check if monitoring is being enabled in the same command
5765+ enable_azure_monitor_logs = self .context .raw_param .get ("enable_azure_monitor_logs" )
5766+ enable_addons = self .context .raw_param .get ("enable_addons" )
5767+ monitoring_being_enabled = (
5768+ enable_azure_monitor_logs or
5769+ (enable_addons and "monitoring" in enable_addons )
5770+ )
57625771
5763- # Resolve the addon profile, handling both "omsagent" and "omsAgent" key variants.
5764- monitoring_addon_profile = None
5765- if mc .addon_profiles :
5766- monitoring_addon_profile = (
5767- mc .addon_profiles .get (CONST_MONITORING_ADDON_NAME ) or
5768- mc .addon_profiles .get (CONST_MONITORING_ADDON_NAME_CAMELCASE )
5769- )
5772+ if not monitoring_being_enabled :
5773+ # Only validate existing addon state when not enabling monitoring simultaneously
5774+ addon_consts = self .context .get_addon_consts ()
5775+ CONST_MONITORING_ADDON_NAME = addon_consts .get ("CONST_MONITORING_ADDON_NAME" )
5776+ CONST_MONITORING_USING_AAD_MSI_AUTH = addon_consts .get ("CONST_MONITORING_USING_AAD_MSI_AUTH" )
5777+
5778+ # Resolve the addon profile, handling both "omsagent" and "omsAgent" key variants.
5779+ monitoring_addon_profile = None
5780+ if mc .addon_profiles :
5781+ monitoring_addon_profile = (
5782+ mc .addon_profiles .get (CONST_MONITORING_ADDON_NAME ) or
5783+ mc .addon_profiles .get (CONST_MONITORING_ADDON_NAME_CAMELCASE )
5784+ )
57705785
5771- if not monitoring_addon_profile or not monitoring_addon_profile .enabled :
5772- raise RequiredArgumentMissingError (
5773- "--enable-high-log-scale-mode requires the Azure Monitor logs addon (omsagent) "
5774- "to be enabled on the cluster. Please enable it first with "
5775- "--enable-addons monitoring or --enable-azure-monitor-logs."
5776- )
5786+ if not monitoring_addon_profile or not monitoring_addon_profile .enabled :
5787+ raise RequiredArgumentMissingError (
5788+ "--enable-high-log-scale-mode requires the Azure Monitor logs addon (omsagent) "
5789+ "to be enabled on the cluster. Please enable it first with "
5790+ "--enable-addons monitoring or --enable-azure-monitor-logs."
5791+ )
57775792
5778- addon_config = monitoring_addon_profile .config or {}
5779- msi_auth_enabled = (
5780- CONST_MONITORING_USING_AAD_MSI_AUTH in addon_config and
5781- str (addon_config [CONST_MONITORING_USING_AAD_MSI_AUTH ]).lower () == "true"
5782- )
5783- if not msi_auth_enabled :
5784- raise RequiredArgumentMissingError (
5785- "--enable-high-log-scale-mode requires MSI authentication to be enabled "
5786- "for the monitoring addon. Please enable it with --enable-msi-auth-for-monitoring."
5793+ addon_config = monitoring_addon_profile .config or {}
5794+ msi_auth_enabled = (
5795+ CONST_MONITORING_USING_AAD_MSI_AUTH in addon_config and
5796+ str (addon_config [CONST_MONITORING_USING_AAD_MSI_AUTH ]).lower () == "true"
57875797 )
5798+ if not msi_auth_enabled :
5799+ raise RequiredArgumentMissingError (
5800+ "--enable-high-log-scale-mode requires MSI authentication to be enabled "
5801+ "for the monitoring addon. Please enable it with --enable-msi-auth-for-monitoring."
5802+ )
57885803
57895804 self .context .set_intermediate ("monitoring_addon_postprocessing_required" , True , overwrite_exists = True )
57905805
@@ -7749,10 +7764,14 @@ def _disable_azure_monitor_logs(self, mc: ManagedCluster) -> None:
77497764
77507765 # Now disable the addon and clear configuration
77517766 mc .addon_profiles [addon_key ].enabled = False
7767+ mc .addon_profiles [addon_key ].config = None
77527768
7753- # Use empty dict instead of None - setting config=None causes the SDK serializer
7754- # to omit the config key entirely, which Azure interprets as "keep existing config"
7755- mc .addon_profiles [addon_key ].config = {}
7769+ # Also disable azureMonitorProfile.containerInsights (the new API surface)
7770+ # The RP uses containerInsights.enabled as the source of truth; if it remains
7771+ # true while the legacy addon is disabled, the RP re-enables the addon.
7772+ if (mc .azure_monitor_profile and
7773+ mc .azure_monitor_profile .container_insights ):
7774+ mc .azure_monitor_profile .container_insights .enabled = False
77567775
77577776 # Also disable OpenTelemetry logs when disabling Azure Monitor logs
77587777 if opentelemetry_logs_enabled :
@@ -7889,7 +7908,10 @@ def update_mc_profile_preview(self) -> ManagedCluster:
78897908 # update acns in network_profile
78907909 mc = self .update_acns_in_network_profile (mc )
78917910 # update update_monitoring_profile_flow_logs
7892- mc = self .update_monitoring_profile_flow_logs (mc )
7911+ # Only call here if the base class doesn't already call it in update_mc_profile_default
7912+ # (CLI >= 2.84.0 added this call to the base class)
7913+ if not hasattr (super (), 'update_monitoring_profile_flow_logs' ):
7914+ mc = self .update_monitoring_profile_flow_logs (mc )
78937915 # update kubernetes support plan
78947916 mc = self .update_k8s_support_plan (mc )
78957917 # update AI toolchain operator
0 commit comments