I am at a loss as to why I cannot run a basic az devops command in an Azure Pipeline using the Classic template.
So basically, I have two Powershell tasks defined for my Classic pipeline and these are:
Task 1: Login to my Azure DevOps organisation using the following commands:
$mytoken = "My_PersonalAccessToken"
echo $mytoken "|" az devops login --organization https://dev.azure.com/OrganisationName
Task 2: List My Azure DevOps Projects
az devops project list
Task 1 works perfectly and login is confirmed as successful.
Task 2 however fails and displays the below error in the pipeline output:
Before you can run Azure DevOps commands, you need to run the login command(az login if using AAD/MSA identity else az devops login if using PAT token) to setup credentials. Please see https://aka.ms/azure-devops-cli-auth for more information.
What could I be doing wrong? Would really appreciate some help, although I must emphasise again that my pipeline uses the Classic template and any proposed solution must be tailored for that.
Mind you, when I run these very same commands in my Powershell ISE editor, both run perfectly and I get all my Azure DevOps projects listed.