Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Powershell Select-AzureSubscription with subscription id

I am using Powershell Azure cmdlets to do some operation on each subscription I have.

However, all my subscriptions have the same name. So if I do an operation like:

$subs | ForEach-Object {
    Select-AzureSubscription -Current -SubscriptionName $_.SubscriptionName
    $services = Get-AzureService
    Write-Output "$($services .Length) services under $($_.SubscriptionId) subscription"
}

it always works for the same subscription because the subscriptions only differ in subscription ID.

And the Select-AzureSubscription does not have a -SubscriptionId parameter.

Any ideas how can I find a workaround?

like image 910
ahmet alp balkan Avatar asked Jan 10 '14 22:01

ahmet alp balkan


2 Answers

Not sure if this was added later, but as of Nov 2015 you can use -SubscriptionId

Write-Host "Selecting Azure subscription using id"
Select-AzureSubscription -SubscriptionId $subscriptionId
like image 129
Rick Glos Avatar answered Oct 10 '22 06:10

Rick Glos


If you are an account administrator for your account, you can change the name of your subscription. This way when you or anyone else who has access to the subscription downloads publishsettings, the name will be set the way you want.

http://rickrainey.com/windows-azure-how-tos/how-to-change-the-name-of-your-windows-azure-subscription/

like image 45
Rick Rainey Avatar answered Oct 10 '22 07:10

Rick Rainey