We are trying to execute this az devops service-endpoint list in a powershell script added in a pipeline in yaml from Azure DevOps
$SubscriptionId = az devops service-endpoint list --organization "https://dev.azure.com/xxxxx" --project $ProjectName --query "[?data.subscriptionName==$SubscriptionName].data.subscriptionId" -o tsv
For executing the command above, The logs tell that we need to login using az devops login --organization https://dev.azure.com/xxxx/ , how do we do this in the pipeline?
Also we use the system access token variable for logging in like this:
$env:AZURE_DEVOPS_EXT_PAT = $env:SYSTEM_ACCESSTOKEN
az loginseparately if you use this task.