diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index abd2a5ee5e4..02a23b89ad8 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -26,6 +26,7 @@ from knack.log import get_logger from knack.util import CLIError +from azure.cli.core.azclierror import CLIInternalError from azure.cli.command_modules.vm._validators import _get_resource_group_from_vault_name from azure.cli.core.commands.validators import validate_file_or_dict @@ -670,6 +671,10 @@ def setter(vm, external_identities=external_identities): vm.identity = VirtualMachineIdentity(type=identity_types) if external_identities: vm.identity.user_assigned_identities = {} + if not cmd.supported_api_version(min_api='2018-06-01', resource_type=ResourceType.MGMT_COMPUTE): + raise CLIInternalError("Usage error: user assigned identity is not available under current profile.", + "You can set the cloud's profile to latest with 'az cloud set --profile latest" + " --name '") for identity in external_identities: vm.identity.user_assigned_identities[identity] = UserAssignedIdentitiesValue()