Azure Powershell Task gives error "Run Login-AzureRMAccount"

Jogalekar, Mandar 56 Reputation points
2022-03-15T13:06:45.943+00:00

I am creating a pipeline to run a powershell script and using with a service connection that is already set up to have contributor rights on the subscription on which i am operating. However the powershell task errors out "Run Login-AzureRMAccount"

Here is my pipeline yaml

 - task: AzurePowerShell@5
   inputs:
   azureSubscription: '****'
   azurePowerShellVersion: LatestVersion
   ScriptType: 'InlineScript'
   Inline: |

[error]Run Login-AzureRmAccount to login.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,013 questions
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,916 Reputation points
    2022-03-22T02:11:21.947+00:00

    Hi @Jogalekar, Mandar

    Could you please try following workarounds to get rid of the "Run Login-AzureRMAccount" error.

    • Most likely this is caused by multiple versions of Azure PowerShell installed on the machine. You can find this out with

    Get-Module -ListAvailable

    If azure powershell modules show up anywhere other than in "%programfiles (x86)%\Microsoft SDKs\Azure\PowerShell", then please try removing them. Try running "Update-Module" command and make sure PowerShell update the modules. Finally restart your machine.

    If you encounter the issue still, try uninstalling all Azure PowerShell modules and reinstalled them with Web Platform Installer.

    Uninstall-Modules AzureRM

    • Try using PowerShell ISE elevated (as administrator). Try to launch the commands in PowerShell ISE to overcome it in the end.
    • Try to create new ServiceBus on Azure Portal. Please ensure your subscription has the permission to create SeviceBus. If you have multiple subscription, please make sure you are using right subscription.

    I hope this helps, but if you have any further questions feel free to come back to us. We are always here to help. Here is a helpful page with information about Microsoft Azure;

    https://learn.microsoft.com/en-us/azure/active-directory/

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

    --If the reply is helpful, please Upvote and Accept as answer.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.