46

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?

Dmitriy
  • 5,525
  • 12
  • 25
  • 38
jon_s_lim
  • 503
  • 1
  • 4
  • 5

3 Answers3

92

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
Bruno Faria
  • 5,219
  • 3
  • 24
  • 27
  • 7
    Thanks, Bruno. After running Add-AzureAccount, I was able to succesfully run the Select-AzureSubscription command without the error. – jon_s_lim Jan 23 '16 at 17:22
  • Also, if you have any tips on running Set-AzureService / Get-AzureService, that would be appreciated. To check the settings for my VM I tried running Get-AzureService "myvmname" (where the VM is at myvmname.cloudapp.net), but got "The hosted service does not exist". – jon_s_lim Jan 23 '16 at 17:36
  • 1
    there's a confusion regarding ARM vs ASM. ARM is a new way of managing resources in azure which can only be created and visualized using the new portal or through PowerShell azureRM cmdlets. Cmdlets like "get-azureservice" are specific to the ASM model. If you're getting "the service does not exist" it's probably because you have deployed your VM using ARM which does not use cloud services for VMs, hence, get-azureservice has no use. Try Get-Command -Module AzureRM.Resources | Get-Help | Format-Table Name, Synopsis – Bruno Faria Jan 23 '16 at 21:43
  • I created the VM a year ago in Jan 2015, so guessing ARM. From the commands, I ran Get-AzureRmResource and see something like: Name : vmname ResourceId : /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/vmname/providers/Microsoft.ClassicCompute/virtualMachines/vmname ResourceName : vmname ResourceType : Microsoft.ClassicCompute/virtualMachines ResourceGroupName : vmname Location : westus SubscriptionId : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Saw something about setting reverse DNS property on the public IP address resource in the article - any ideas which command to use? – jon_s_lim Jan 23 '16 at 22:22
  • 1
    Please ignore last comment - looks like my VM was associated with my Visual Studio Premium account, but I had set my default subscription to Visual Studio Enterprise. After switching the default subscription, the Get/Set-AzureService commands worked perfectly. Which also means I'm on ASM. Thanks! – jon_s_lim Jan 23 '16 at 23:45
  • great!! if you see the resources in the classic portal, then it's ASM :) – Bruno Faria Jan 24 '16 at 01:36
  • The **Add-AzureAccount** statement is crucial when dealing with classic services. I was trying to deploy a Cloud Service with extensions. Select-AzureRmSubscription did not work in this situation. However, once I ran Add-AzureAccount cmdlet before Select-AzureSubscription everything ran fine. – user3613932 Jan 24 '17 at 04:22
2

The problem you're having is that the 'default' parameter is depreciated.

if you run

Select-AzureSubscription -SubscriptionName "Visual Studio Premium with MSDN" `
                         -Default "Visual Studio Premium with MSDN"

You get -

WARNING: Current and Default parameters have been deprecated. Select-AzureSubscription will always update the Default Subscription

If you just run

 Select-AzureSubscription -SubscriptionName "Visual Studio Premium with MSDN"  

You should get the result you're looking for.

Michael B
  • 11,887
  • 6
  • 38
  • 74
  • 1
    Thanks, Michael. Unfortunately I still got the same error message with this. Looks like Add-AzureAccount was needed as well in my case. – jon_s_lim Jan 23 '16 at 17:21
  • However, you were correct that -Default is deprecated and I had to use the -SubscriptionName flag – jon_s_lim Jan 23 '16 at 17:24
  • Also, if you have any tips on running Set-AzureService / Get-AzureService, that would be appreciated. To check the settings for my VM I tried running Get-AzureService "myvmname" (where the VM is at myvmname.cloudapp.net), but got "The hosted service does not exist" – jon_s_lim Jan 23 '16 at 17:37
1
  • Connect-AzureRmAccount then login to Azure as normal
  • Run the command cmdlet Get-AzureRmSubscription –SubscriptionName "<name>" | Select-AzureRmSubscription (see answer by @Bruno Faria)
Chris Halcrow
  • 28,994
  • 18
  • 176
  • 206