Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure powershell Select-AzureSubscription - error: the subscription name doesn't exist

I've just installed the latest powershell 1.1 and am following this blog entry to add reverse DNS to an existing Linux VM that I am running

https://azure.microsoft.com/en-us/blog/announcing-reverse-dns-for-azure-cloud-services/

I was able to log in and run Get-AzureRmSubscription to see my subscriptions:

SubscriptionName : Visual Studio Premium with MSDN SubscriptionId   : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX TenantId         : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX  SubscriptionName : Visual Studio Enterprise with MSDN SubscriptionId   : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX TenantId         : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 

If I try to run the Set-AzureService command, an error message tells me I need to set a default subscription

I've tried

Select-AzureSubscription -Default 'Visual Studio Enterprise with MSDN'  Select-AzureSubscription -Default "Visual Studio Enterprise with MSDN"  Select-AzureSubscription -Default 'Visual Studio Premium with MSDN'  Select-AzureSubscription -Default "Visual Studio Premium with MSDN" 

I've even tried just running Select-AzureSubscription and then entering the subscription name when prompted, with no quotes, single quotes, and double quotes, and haven't been able to get this to work.

I keep getting an error saying something like "The subscription name 'Visual Studio Enterprise with MSDN' doesn't exist".

I've also tried doing this using "Select-AzureSubscription -SubscriptionID" with the subscription IDs listed, with similar results.

What am I doing wrong?

like image 458
jon_s_lim Avatar asked Jan 23 '16 09:01

jon_s_lim


People also ask

How do I select Azure subscription in PowerShell?

To change the azure subscription using PowerShell, we can use the Select-AZSubscription command. When you use this command, you can use either the subscription ID, Subscription Name, or the Tenant ID.

How do I join a specific subscription on Azure?

To connect to the specific azure subscription using Az CLI we need to use “Az account set” command but before using this command make sure you are connected with the Azure cloud using “az login” account. You can also use -s instead of --subscription.

How do I set up an Azure PowerShell subscription?

To create and provision an Azure subscription, visit the Azure Portal (https://azure.microsoft.com/). This cmdlet changes the data in the subscription data file that you create when you use the Add-AzureAccount or Import-AzurePublishSettingsFile cmdlet to add an Azure account to Windows PowerShell.


1 Answers

If you are using Resource Manager, the correct cmdlet is:

Get-AzureRmSubscription –SubscriptionName "<name>" | Select-AzureRmSubscription 

or just use -SubscriptionId instead of -SubscriptionName.

Select-AzureSubscription is to be used to manage classic resources. To make it work you also have to add classic credentials using:

Add-AzureAccount 
like image 90
Bruno Faria Avatar answered Oct 07 '22 14:10

Bruno Faria