ruth1613
ruth1613

Reputation: 51

Get-AzureVM does not show virtual machine

I'm using the Azure Free Trial and following the Cloud Ranger training videos. I have loaded the SDK to Powershell and I can add-azureaccount and get-azuresubscription with no problem. I only have one subscription so I'm definitely in the right one.

The display after Get-AzureSubscription does not list any supported modes and I can't see any of my services listed -- When I use Get-AzureVM nothing displays. I have a vm, cloud service and a storage account set up in the Azure portal. I can see them in the portal, but can't see them in PS.

Upvotes: 1

Views: 3578

Answers (2)

ruth1613
ruth1613

Reputation: 51

Finally figured it out. I wanted to post in case someone in the future runs into this problem. I thought the problem might be eliminated when I went from the Azure Free Trial to Pay as You Go. But it surfaced again. I created vms in the portal (both in Preview and Manage) but they wouldn't show up in Powershell with Get-AzureVM no matter what I tried. Finally I gave up and created one in Powershell and then Get-AzureVM returned all the VMs.

Upvotes: 2

paulsm4
paulsm4

Reputation: 121829

Here is an example session:

  1. Download and Install Azure PowerShell

  2. Start Powershell: powershell

  3. Log on to Azure: Add-AzureAccount <= This displays an authentication pop-up for login

  4. Check subscription(s): Get-AzureSubscription <= Everything looks fine...

  5. Check RM VMs: Get-AzureRMContext <= This fails:

Get-AzureRMContext : Run Login-AzureRmAccount to login. At line:1 char:1 + Get-AzureRMContext + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Get-AzureRmContext], PSInvalidOperationException + FullyQualifiedErrorId : InvalidOperation,Microsoft.Azure.Commands.Profile.GetAzureRMContextCommand

  1. Run separate login-AzureRmAccount <= Get another login popup

  2. Check content Get-AzureRMContext <= OK

  3. Re-run Get-AzureRMVM <= Everything works this time: see expected server and server details

  4. I was also able to run Get-AzureWebsite (to see my deployed REST services), etc.

  5. Use help Get-Azure for a complete list of query commands.

NOTE:

Dealing with Powershell syntax can be a PITA.

So it's extremely important to make sure everything looks OK in the portal. That way, you can focus on troubleshooting a PS syntax error - rather than a real configuration problem.

'Hope that helps!

PS:

Here's a useful "cheat sheet":

https://www.opsgility.com/blog/windows-azure-powershell-reference-guide/getting-started-with-windows-azure-powershell/

Upvotes: 1

Related Questions