Tuesday, April 7, 2015

Failed to get Microsoft Azure resources by PowerShell

If you added more than 1 Microsoft Azure account for testing by perform "Add-AzureAccount" into PowerShell, you would have the following issue when you get Azure resources.

When I try to get Microsoft Azure Virtual Network Gateway by performing "Get-AzureVNetGateway", I found an error.

However, I created this gateway on Microsoft Azure portal. Then, I performed "Get-AzureSubscription" to check my Azure subscription.

I found that it pointed to the other Azure subscription account and configured to "IsDefault". To update the Azure subscription, we can perform  "Select-AzureSubscription -SubscriptionId <SubscriptionId> -Current -Account <Azure Account>" to select and use this Azure subscription.

Remark: We can perform  "Select-AzureSubscription -SubscriptionId <SubscriptionId> -Default -Account <Azure Account>" to update the default Azure subscription.

As a result, I can get the virtual network gateway information from this Azure subscription.

This posting is provided “AS IS” with no warranties, and confers no rights!

No comments:

Post a Comment