diff --git a/src/azure-cli/azure/cli/command_modules/acs/custom.py b/src/azure-cli/azure/cli/command_modules/acs/custom.py index 63500b7c9d2..73463a99052 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/custom.py @@ -875,6 +875,8 @@ def aks_enable_addons(cmd, client, resource_group_name, name, addons, msi_auth = False if instance.service_principal_profile.client_id == "msi": msi_auth = True + else: + enable_msi_auth_for_monitoring = False subscription_id = get_subscription_id(cmd.cli_ctx) instance = _update_addons(cmd, instance, subscription_id, resource_group_name, name, addons, enable=True, diff --git a/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py b/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py index 59e5e20144c..6be245ffcd4 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py +++ b/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py @@ -2608,6 +2608,12 @@ def get_enable_msi_auth_for_monitoring(self) -> Union[bool, None]: # read the original value passed by the command enable_msi_auth_for_monitoring = self.raw_param.get("enable_msi_auth_for_monitoring") + if ( + self.mc and + self.mc.service_principal_profile and + self.mc.service_principal_profile.client_id is not None + ): + return False # try to read the property value corresponding to the parameter from the `mc` object if ( self.mc and @@ -5373,9 +5379,9 @@ def build_monitoring_addon_profile(self) -> ManagedClusterAddonProfile: enabled=True, config={ CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID: self.context.get_workspace_resource_id(), - CONST_MONITORING_USING_AAD_MSI_AUTH: "True" + CONST_MONITORING_USING_AAD_MSI_AUTH: "true" if self.context.get_enable_msi_auth_for_monitoring() - else "False", + else "false", }, ) # post-process, create a deployment diff --git a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py index 4ea8d76f88b..86e7ea8d438 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py +++ b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py @@ -7494,8 +7494,7 @@ def test_aks_create_with_monitoring_legacy_auth(self, resource_group, resource_g '--ssh-key-value={ssh_key_value} ' response = self.cmd(create_cmd, checks=[ self.check('addonProfiles.omsagent.enabled', True), - self.exists('addonProfiles.omsagent.config.logAnalyticsWorkspaceResourceID'), - self.check('addonProfiles.omsagent.config.useAADAuth', 'false') + self.exists('addonProfiles.omsagent.config.logAnalyticsWorkspaceResourceID') ]).get_output_in_json() # make sure a DCR was not created diff --git a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py index 8563f88e91e..7b0c42a4962 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py +++ b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py @@ -2312,7 +2312,7 @@ def test_get_enable_msi_auth_for_monitoring(self): addon_profiles_1 = { CONST_MONITORING_ADDON_NAME: self.models.ManagedClusterAddonProfile( enabled=True, - config={CONST_MONITORING_USING_AAD_MSI_AUTH: "True"}, + config={CONST_MONITORING_USING_AAD_MSI_AUTH: "true"}, ) } mc = self.models.ManagedCluster(location="test_location", addon_profiles=addon_profiles_1) @@ -6016,7 +6016,7 @@ def test_build_monitoring_addon_profile(self): enabled=True, config={ CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID: "/test_workspace_resource_id", - CONST_MONITORING_USING_AAD_MSI_AUTH: "False", + CONST_MONITORING_USING_AAD_MSI_AUTH: "false", }, ) self.assertEqual(monitoring_addon_profile, ground_truth_monitoring_addon_profile) @@ -6291,7 +6291,7 @@ def test_set_up_addon_profiles(self): enabled=True, config={ CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID: "/test_workspace_resource_id", - CONST_MONITORING_USING_AAD_MSI_AUTH: "False", + CONST_MONITORING_USING_AAD_MSI_AUTH: "false", }, ), CONST_VIRTUAL_NODE_ADDON_NAME