PowerShell and Azure: some gotchas

Elsewhere I’ve referenced Keith Mayer. As I needed to remind myself how I did a backup, I started out with “his” suggested first command…

Get-AzureVM

However… that gave me this one:

Get-AzureVM : No current subscription has been designated. Use Select-AzureSubscription -Current <subscriptionName> to
set the current subscription.

Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand

AzureS201

So try that, although at first I have no idea of my subscription…

AzureS202

Mystery solved, I think: in fact when you go into PowerShell for Azure, the first thing you need to do is not any of the Subscription-sounding functions, but this, i.e. enter

Add-AzureAccount

, that takes you to a credentials dialogue. Once you OK that, it confirms all your details:

AzureS203

But Get-AzureVM still didn’t work… well it didn’t find it, more accurately. So I downloaded it (Azure for PowerShell), and this time it was found. The old blog page gave me the rest of it, more or less.. Here’s where I am now, finishing for the night:

AzureS204 AzureS205 AzureS206 AzureS207

This, in fact is a useful piece:

AzureS208

April 2015

I see that the error message has been made more helpful when your credentials have expired when entering [Get-AzureVM], in that it actually tells you what to do now:

AzureLoginFailed01

Get-AzureVM : Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your Azure credentials.

AzureLoginFailed02

Now run Get-AzureVM again, and they changed the formatting a bit as well:

AzureLoginFailed03

So in summary, after you’ve been away a while, the 2 commands to get to a point where you list your VMs are:

Add-AzureAccount
Get-AzureVM
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s