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 61c5b4b7b40..b776de5be20 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 @@ -8353,10 +8353,16 @@ def test_aks_create_with_outbound_type_udr(self, resource_group, resource_group_ # role assignment assignee_object_id = _get_test_sp_object_id(sp_name) - role_assignment_cmd = ( - 'role assignment create --scope {vnet_id} --role "Network Contributor" ' + - ("--assignee-object-id " + assignee_object_id) if assignee_object_id else "--assignee {service_principal}" - ) + if assignee_object_id: + role_assignment_cmd = ( + 'role assignment create --scope {vnet_id} --role "Network Contributor" ' + f"--assignee-object-id {assignee_object_id} --assignee-principal-type ServicePrincipal" + ) + else: + role_assignment_cmd = ( + 'role assignment create --scope {vnet_id} --role "Network Contributor" ' + "--assignee {service_principal}" + ) self.cmd(role_assignment_cmd, checks=[ self.check('scope', vnet_id) ])