azure-pipelines-tasks: [REGRESSION]: AzurePowerShell stopped working with 'Resolve-Error' not recognized.

New issue checklist

Task name

AzurePowerShell

Breaking task version

5.247.5

Last working task version

5.246.1

Regression Description

Attempting to run an inline script using AzurePowerShell generates the following error message:

An error occurred in Initialize-AzModule
##[error]The term 'Resolve-Error' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
##[error]PowerShell exited with code '1'.
Finishing: Download from Azure

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows Server 2019 Datacenter

Relevant log output

An error occurred in Initialize-AzModule ##[error]The term ‘Resolve-Error’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. ##[error]PowerShell exited with code ‘1’. Finishing: Download from Azure

Full task logs with system.debug enabled

UNSUCCESSFUL RUN
 [REPLACE THIS WITH YOUR INFORMATION] 
SUCCESSFUL RUN
 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 5
  • Comments: 24 (6 by maintainers)

Most upvoted comments

Why does it take so long to implement such a simple change ? Someone actually has made a pull request (https://github.com/microsoft/azure-pipelines-tasks/pull/20955) Customers are warned beforehand that Resolve-Error will be removed, but Microsoft seemes to ‘forget’ to update their own code. Even when an issue is raised, nothing happens for months. I am stuned…

It’s more than just a single-line change. Using Resolve-AzError fixes the issue when the Az module is installed, but users who try to run the task on a machine without the module will encounter the same “not recognized as the name of a cmdlet, function, script file, or operable program” error. It needs to be fixed to not rely on that method in the Az module at all, so that Initialize-AzModule’s message about the module being missing is reported to the user.

Replacing Resolve-Error by Resolve-AzError will not change the behaviour, so the problem with Resolve-AzError not being available when the Az module is not loaded is no different then Resolve-Error. And further more, I would expect that after 9 months someone can come up with a solution to detect this situation and act upon it. By not solving the issue, you effectively can not use the Az 14.x.x powershell module with the Azure Pipelines Tasks extensions. I think this is unacceptable.