none
Azure Automation: error "Run Login-AzureRmAccount to login."

    Question

  • Hello,

    In a Azure Enterprise subscription, I am trying to get Azure Automation Service working properly.
    I am NOT using the main account of the subscription but my own account having admin rights on the portal but without the billing stuff. 

    I created a 'Automation account', and trying to add custom 'powershell workflow' runbooks.

    But none is working properly. All the default 'Tutorial' scripts also failed with the logging error. E.g. AzureAutomationTutorialScript fails on Login-AzureRmAccount.

    Get-AzureRmResourceGroup : Run Login-AzureRmAccount to login.
    At line:35 char:19
    + $ResourceGroups = Get-AzureRmResourceGroup
    +                   ~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Get-AzureRmResourceGroup], PSInvalidOperationException
        + FullyQualifiedErrorId : InvalidOperation,Microsoft.Azure.Commands.Resources.GetAzureResourceGroupCommand

    What should I do to make the automation works properly?

    I added credentials for my account but AFAIK, the automation engine should not need extra credential, shout it?


    Monday, January 23, 2017 2:31 PM

All replies

  • Greetings!

    Thank you for contacting Microsoft forums.

    The query posted by you has not reached the right forum. In order to assist best on your query, I am moving the query to the right forum.

    This will assist you with a faster reply to your query.

    In the meantime, there is a discussion on similar query here kindly check the steps outlined.

    Regards,
    Ajay

    ---------------------------------------------------------------------------------------------------

    Kindly click "Mark as Answer" on the post that helps you, this can be beneficial to other community members reading the thread and ‘Vote as Helpful’

    Tuesday, January 24, 2017 10:26 AM
    Moderator
  • This error is occurring as the version of AzureRM.Profile and AzureRM.Resources modules are of different version in the above automation account. If you update all the AzureRM modules to same version then the above error will go away and AzureAutomationTutorialScript will work.

    Please use the Update-ModulesInAutomationToLatestVersion  script from PowerShellGallery to update all the AzureRM modules.

    Steps to use the script

    1) Please Click Runbooks => Browse Gallery => Click on Filter => Set the Gallery Source to PowerShellGallery => Click OK in Filter Screen => Search for Update-ModulesInAutomationToLatestVersion.
    2) Please make sure the AzureRM.Profile  and AzureRM.Automation are of same version if not Update-ModulesInAutomationToLatestVersion  will not work.
    3) This Update-ModulesInAutomationToLatestVersion  needs RunAsAccount.

    4) If there is any scheduled run book which is using the AzureRM Modules then please unlink the schedule and relink the schedule.

    Tuesday, January 24, 2017 1:53 PM
  • thanks for the answer, even I did not read it 'on time': I eventually removed the automation account and created a new one, and everything went fine!

    Tuesday, February 14, 2017 9:01 AM
  • You need to give service principal for authentication in Azure automation runbooks. Your current automation connection can help you to resolve this error. Refer to the below link for the details about the same - 

    http://sanganakauthority.blogspot.in/2017/05/run-login-azurermaccount-to-login.html


    http://sanganakauthority.blogspot.com/

    Sunday, May 07, 2017 8:24 AM