Azure PowerShell throws the error "Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your Azure credentials" when you try to run a PS command against an Azure service. This is using both the Get-AzurePublishSettingsFile and the Add-AzureAccount methods to authenticate to the Azure tenancy.
This is because there are a number of stale entries related to your account cached on the administrative device you are using, to display all of the cached accounts use the following command;
Get-AzureAccount
|
The following command can be used to delete all of the cached Azure credentials from the device;
foreach ($AzureAccount in (Get-AzureAccount).ID)
{Remove-AzureAccount $AzureAccount}
|
Then try Add-AzureAccount, enter your credentials.
And you should re-authenticate to the Azure tenancy properly. You can now run any commands without being faced with the same error.