How to forcing Powershell to use new Azure Subscription

Viewed 11494

I have two subscription one with old cloud service and other is with new cloud service. I am using Powershell to access my new subscription. I have downloaded latest .publishsettings and set it using Import-AzurePublishSettingsFile. My problem is that I always get the old subscription set and could not figureout how to force powershell to use my new subscription.

3 Answers

Just to clarify, there are two kinds of 'special' subscriptions, the 'current' subscription (which is the subscription used for any command in the current PowerShell session), and the Defaul subscription, which is the subscription used even after the current PowerShell session ends.

using Select-AzureSubscription <subscription-name> will set the current subscription. If you'd like to change the subscription across sessions, use Select-AzureSubscription -Default <subscription name>

This answer is for the classic Azure management. If you're on the new ARM then you want to do something like

Login-AzureRmAccount
Get-AzureRmSubscription
Set-AzureRmContext -SubscriptionId blah

where blah is the subscription ID from the second command

Related