In Azure, when you have an enterprise subscription, Microsoft is kind enough to give you a default subscription name. While that’s cool – its not really when you spin up multiple subscriptions and then try to use azure powershell to control them.
The main problem:
Select-AzureSubscription -SubscriptionName (name) -Current
Hard to do, when you have 2+ subscriptions with the same name.
If you find yourself in that boat, first thing first – rename your subscriptions to something meaningful.
Login to your account at https://account.windowsazure.com/subscriptions.
Click on the subscription you want to rename. That will open up some more detailed view of it.
On the right side of the screen, click on the link for Edit subscription details.
Now then, clean up your azure powershell environment, its not automatic. Two places to look here – certificate store and a json file in the powershell folder.
The json file is located in C:\Users\(username)\AppData\Roaming\Windows Azure Powershell\ AzureProfile.json
The certificates are in your certificates MMC console, under personal certificates.
Delete the offendingly named certificate. Either Edit the json file or delete it – Note have powershell closed completely before deleting the json file otherwise, you’ll discover that it writes the file back with the original settings in place. Trust me, I went there.
Last thing to do, pull down the certificate from Azure and import it again. You’ll need your azure subscription login and the get command will open a webpage to start the download. Of course, if you’re doing this because your powershell is screwed up, you already knew this.
Get-AzurePublishSettingsFile
Import-AzurePublishSettingsFile 'C:\temp\(filename)-credentials.publishsettings'
Use this command to list your subscriptions and set the right one as current:
Get-AzureSubscription
Select-AzureSubscription -SubscriptionName (name) -Current