Friday, September 19, 2014

How To Link your Microsoft Account to Azure Powershell

Today I was trying to get the WadConfig.xsd file via the Azure Powershell window with this command:

  1. (Get-AzureServiceAvailableExtension -ExtensionName 'PaaSDiagnostics' 
  2. -ProviderNamespace 'Microsoft.Azure.Diagnostics').PublicConfigurationSchema | 
  3. Out-File -Encoding utf8 -FilePath 'WadConfig.xsd' 
But, I received this error (shown below):  No current subscription has been designated.  Use Select-AzureSubscription -Current <subscriptionname> to set the current subscription.
 
I tried to execute Select-AzureSubscription, but no dice there, it wouldn't recognize that I had any Azure subscriptions. 
 
[insert frustration and thirty minutes of searching for a solution]
 
I finally found a hint in Powershell.  I was trying many different commands that I found, and I stumbled across this command:
 
Add-AzureAccount
 
I had, wrongly, assumed that Powershell would "just know" who I am based on the Microsoft Account with which I had logged in.  But, nope.  It turns out that my Microsoft Account has both an "organizational" and "personal" aspect.  I logged into my machine with the "personal" aspect account, and my Azure subscriptions are linked to my "organization" aspect.  Grrr.
 
So, after running the Add-AzureAccount command, I was prompted for my Microsoft Account credentials, entered my "organization" credentials and then voila my Azure subscriptions showed up!!!
 
Now that my Microsoft Account was associated with Powershell, I was able to run:
Set-AzureSubscription -SubscriptionId '{My Subscription Id from the list above}'
 
And then when I ran the command to get the WadConfig.xsd, it worked!
 
 

No comments:

Post a Comment