locked
Azure Script not working on Azure Portal. RRS feed

  • Question

  • Hi,

    I have a very simple script for azure:

    Select-AzureSubscription $subscriptionName

    I can execute it properly in powershell in my machine.

    However, when I paste it on portal.azure.com runbook, and run it, it says:

    Select-AzureSubscription : The subscription name MySubscriptionName doesn't exist.

    Can anyone tell me what are the possible reasons behind this?

    Wednesday, January 20, 2016 3:15 PM

Answers

  • I found the problem now. My code is an Azure Classic one while the Azure Account I have should be using AzureRM.

    Microsoft changed some coding on the azure last December, which obviously I wasn't aware of.

    Thanks for the reply anyways.

    • Marked as answer by Oscarlito Wednesday, February 3, 2016 2:54 PM
    Wednesday, February 3, 2016 2:54 PM

All replies

  • As long as the subscription name is wrote correct and the user that is logged in the portal has access to the subscription it should work. 

    Could you double check (even if I'm sure that you already done this):

    • Subscription name is correct
    • The user that is logged in had writes to the given subscription
    Wednesday, January 20, 2016 3:23 PM
  • Wednesday, January 20, 2016 3:34 PM
  • I'll be honest I just started learning Azure coding 3days ago, so I was doing it in powershell first. (which is in concept 100% similar with azure powershell runbook).

    My code is just like this:

    Add-AzureAccount -Credential $cred

    $subscriptionName = "MySubscription"
    Select-AzureSubscription $subscriptionName
    Get-AzureSubscription -Current
    Get-AzureSubscription -Default

    In powershell, it perfectly works, but in portal.azure, it wont.

    I have this error: 

    Add-AzureAccount : The given key was not present in the dictionary.
    

    I read some post about my error so i added this:

    Remove-AzureAccount -Name $userName -Force;
    Clear-AzureProfile -Force;

    but i got this error instead:

    Remove-AzureAccount : User name is not valid.
    

    which is I am sure is valid because 1st it worked in powershell, and 2nd it is my azure account.

    now, i am lost. :(

    Thursday, January 21, 2016 10:21 AM
  • Follow all the steps from the below link and you should be able to use use Azure Automation without any problems.

    https://azure.microsoft.com/en-us/documentation/articles/automation-configuring/

    Friday, January 22, 2016 1:04 PM
  • Sadly I can't create everything on your reply, thanks BTW though.

    I think I know the reason now. It's because my manager only assigns me as "Owner" of my Subscription but not an Administrator or Co-Administrator.

    What I still can't understand though is why can do it in Azure PS in my laptop but not in the Portal. Maybe it's a bug, maybe it's a feature, but let's see if they'll give me that subscription role privilege.

    Friday, January 22, 2016 4:17 PM
  • I found the problem now. My code is an Azure Classic one while the Azure Account I have should be using AzureRM.

    Microsoft changed some coding on the azure last December, which obviously I wasn't aware of.

    Thanks for the reply anyways.

    • Marked as answer by Oscarlito Wednesday, February 3, 2016 2:54 PM
    Wednesday, February 3, 2016 2:54 PM