Monday, December 15, 2014

Your Azure credentials have not been set up or have expired

Is the message Azure Credentials have not been set up or have expired bothering you?


Most of you probably use PowerShell to manage and administer your Microsoft Azure Subscriptions. One of the challenge you might find is that your PowerShell session to Microsoft Azure instantaneously expires.. Very frustrating..

get-azurevm : Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your
Azure credentials.
At line:1 char:1
+ get-azurevm
+ ~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureVM], ArgumentException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand
Azure session expired

To work around this problem simply run the Remove-AzureAccount PowerShell cmdlet. This allows you to delete active or expired sessions that might have been set up through the Microsoft Azure PowerShell.

Remove-AzureAccount

Once deleted, run the Add-AzureAccount command, logon and connect to the desired subscription. After that you'll find that you'll be able to run the get-AzureVM command without any error messages.

Session re-established