Windows – Add-AzureAccount : unknown_user_type: Unknown User Type on azure automation

azurepowershellscriptingwindows

I am getting following error on azure automation when I trying to connect VM.
Also follow this link https://stackoverflow.com/questions/29899964/azure-powershell-automation-no-default-subscritpion-has-been-designated

1/4/2016 3:33:14 PM, Error: Add-AzureAccount : unknown_user_type: Unknown User Type
At New-AzureVMEndpoint:16 char:16

1/4/2016 3:33:14 PM, Error: Get-AzureVM : No default subscription has been designated. Use Select-AzureSubscription -Default to
set the default subscription.
At New-AzureVMEndpoint:20 char:20
+
done

My Code :

workflow New-AzureVM
{

[String]  $AzureCredentialAssetName = 'AzureCredential'       
[String]  $AzureSubscriptionIdAssetName = 'dxxxxxx-xxxxxxx'

# Returns strings with status messages 
[OutputType([String])] 

# Connect to Azure and select the subscription to work against 
$Cred = Get-AutomationPSCredential -Name $AzureCredentialAssetName 
$SubId = Get-AutomationVariable -Name $AzureSubscriptionIdAssetName 

$AzureAccount = Add-AzureAccount -Credential $Cred

Get-AzureAccount
Get-AzureVM
echo "done"
}

If I Select-AzureSubscription -Default 'SubscriptionName' it throws an error saying the syntax is invalid.

Also I try to use azure in-build templates for connect the VM but on every script getting this error : Add-AzureAccount : unknown_user_type: Unknown User

Best Answer

Please see https://social.msdn.microsoft.com/Forums/en-US/a4f5ac38-db33-4082-a3de-b4b8d501b35a/addazureaccount-unknownusertype?forum=azureautomation.

Make sure the credential asset name (not username) is a simple string. Also make sure the credential asset username is a valid OrgID user (ex: abc@fdgdf.onmicrosoft.com), not a Microsoft / Live account (joe@gmail.com).