Q: I'm using PowerShell to manage Azure, and I've imported a Publish Settings file. However, when I try to perform operations, I get an error message that credentials haven't been set. What can I do?
A: Azure is moving away from the management certificates that give administrator rights in a subscription and that are independent of a specific user and is instead moving to Azure Resource Manager, which features full role-based access control (RBAC) specific to the user and the groups the user is in. If you load a Publish Settings file via Import-AzurePublishSettingsFile and then try to access an Azure resource, you might get an error message such as the following:
Get-AzureVM : Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your Azure credentials.
This is because at some point you used an Azure Active Directory account with Azure in PowerShell on the machine, which will take precedence and going forward will require an account to be specified. One solution would be to use Remove-AzureAccount, which would remove the Azure Active Directory account from the PowerShell environment (but won't delete it from Azure):
Remove-AzureAccount -Name [email protected]
The old certificate-based management with X.509 certificates should now work again.
It's important to note, however, that Azure is moving to Azure Resource Manager, which isn't compatibile with the old management certificates—which don't understand RBAC. My advice is to move away from using the certificates and Publish Settings files and instead use Azure Active Directory accounts. This means that instead of importing a Publish Settings file at the start of your PowerShell session, you would use
which would open a browser window where you would sign in. To start using the PowerShell cmdlets that utilize Azure Resource Manager, use
For more information about the modes, see "Using Windows PowerShell with Resource Manager."