-
Notifications
You must be signed in to change notification settings - Fork 263
Description
Is your feature request related to a problem? Please describe.
I tried to open a bug or issue report here as I was directed to in this issue: Azure/azure-cli#31591 (comment). However, the interface only allows submitting a feature and not a issue/bug.
The issue I am having is the use of AZ CLI using the azure-devops extension. When using the task: AzureCLI@2 in Azure Devops YAML pipelines, I am now receiving the following fatal error when using AZ CLI commands. Although this is a UserWarning, it causes the pipeline to fatally fail at the end of the run. This is just a warning and this warning just started happening (to a lot of people) when it did not happen before. It is a deprecation warning and should not be treated as a fatal error.
/opt/az/azcliextensions/azure-devops/azext_devops/dev/__init__.py:5: **UserWarning:** pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
**##[error]/**opt/az/azcliextensions/azure-devops/azext_devops/dev/__init__.py:5: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
Example Azure DevOps Task:
I have had the same issue this week. In my case I am also using the hosted Unbuntu 24.04 image and the 'warning' is bubbling up as a terminal error when using an AzureCLI task with failOnStandardError: true. This is a UserWarning, but creates an ##[error] as seen below.
- task: AzureCLI@2
inputs:
azureSubscription: 'mySubscription'
ScriptType: 'pscore'
scriptLocation: 'inlineScript'
visibleAzLogin: false
**failOnStandardError: true**
Example Output:
Starting: Get Pipeline Execution Count
==============================================================================
Task : Azure CLI
Description : Run Azure CLI commands against an Azure subscription in a PowerShell Core/Shell script when running on Linux agent or PowerShell/PowerShell Core/Batch script when running on Windows agent.
Version : 2.256.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-cli
==============================================================================
/usr/bin/az --version
azure-cli 2.74.0
core 2.74.0
telemetry 1.1.0
Extensions:
azure-devops 1.0.1
Dependencies:
msal 1.32.3
azure-mgmt-resource 23.3.0
Python location '/opt/az/bin/python3'
Config directory '/home/vsts/.azure'
Extensions directory '/opt/az/azcliextensions'
Python (Linux) 3.12.10 (main, May 27 2025, 09:12:37) [GCC 13.3.0]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Setting AZURE_CONFIG_DIR env variable to: /home/vsts/work/_temp/.azclitask
Setting active cloud to: AzureCloud
/usr/bin/az cloud set -n AzureCloud
/opt/az/azcliextensions/azure-devops/azext_devops/dev/__init__.py:5: **UserWarning:** pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
**##[error]/**opt/az/azcliextensions/azure-devops/azext_devops/dev/__init__.py:5: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
Example commands and failures:
$ReposArrayList = [System.Collections.ArrayList]($(az repos list -o json | convertfrom-json | where-object { $_.name -like '�df-*' }).name)
/opt/az/azcliextensions/azure-devops/azext_devops/dev/__init__.py:5: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
$PRArrayList = $(az repos pr list --repository adf-aac --creator --status active -o json | convertfrom-json | where-object { .title -eq 'Update ADO pipeline from adf-standards' }).codeReviewId
/opt/az/azcliextensions/azure-devops/azext_devops/dev/__init__.py:5: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
$Branches = $(az repos ref list --repository $Repo --filter 'heads/update-pipeline-branch-' -o json | convertfrom-json)
/opt/az/azcliextensions/azure-devops/azext_devops/dev/__init__.py:5: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
Describe the solution you'd like
I am not sure how this can be properly handled, but an internal command that we we do not have access to edit is writing a warning deprecation to the output. That output is automatically being interpreted as a fatal error and quitting. When an actual error happens, I want to ensure we quit with a fatal error. However, a warning should just be displayed so we are aware. Having the option to show warnings (like deprecations) in the pipeline Summary page is helpful for visibility.
Additional context
Related tickets:
Azure/azure-cli#31591
Azure/azure-cli-extensions#8833
Azure/azure-cli#31616
Azure/azure-cli#30276
actions/runner-images#12403
actions/runner-images#12361
Azure/azure-cli#26330