Skip to content

Conversation

@jiasli
Copy link
Member

@jiasli jiasli commented Dec 16, 2021

Description

Show msal and azure-mgmt-resource versions, as proposed at #20723 (comment).

In this way, we can easily troubleshoot issues caused by dependency issues like #20723, #20503, #20304, #20138, #20101, #19557, #19502, #19357, #19209, #19169, #19168, #18918, #18791, #18532.

(Query: https://github.com/Azure/azure-cli/issues?q=is%3Aissue+got+an+unexpected+keyword+user_agent)

After this PR:

> az --version
azure-cli                         2.31.0

core                              2.31.0
telemetry                          1.0.6

Extensions:
alias                              0.5.2

Dependencies:
msal                              1.16.0
azure-mgmt-resource               20.0.0

Python location 'D:\cli\py310\Scripts\python.exe'
Extensions directory 'C:\Users\jiasli\.azure\cliextensions'

Python (Windows) 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

az feedback will also include such information:

Windows-10-10.0.19044-SP0
Python 3.10.0
Installer: PIP

azure-cli 2.31.0

Extensions:
alias 0.5.2

Dependencies:
msal 1.16.0
azure-mgmt-resource 20.0.0

Indeed, there may be issues related to other Track 2 SDKs or dependencies, but they happen less often and we can solve them on a per-issue basis.

Comment on lines 446 to 470
ext_line = -1
legal_line = -1
for i, line in enumerate(lines):
if line.startswith("azure-cli"):
line = " ".join(line.split())
new_lines.append(line)
if line.lower().startswith("extensions:"):
ext_line = i
continue
l_lower = line.lower()
if all(["legal" in l_lower, "docs" in l_lower, "info" in l_lower]):
legal_line = i
if 'python location' in line.lower():
break
new_lines.append(line)

new_lines.append("")

if 0 < ext_line < legal_line:
for i in range(ext_line, legal_line):
l_lower = lines[i].lower()
if "python location" in l_lower or "extensions directory" in l_lower:
break

line = " ".join(lines[i].split())
new_lines.append(line)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to parse the output of az --version in such detail. Simply remove consecutive spaces and it will work, given we don't need to minify the body of az feedback anymore (#17353).

Comment on lines 434 to 443
# Add azure-mgmt-resource version
try:
# pylint: disable=protected-access
from azure.mgmt.resource._version import VERSION as azure_mgmt_resource_version
except ImportError:
try:
from azure.mgmt.resource.version import VERSION as azure_mgmt_resource_version
except ImportError:
azure_mgmt_resource_version = "N/A"
versions['azure-mgmt-resource'] = azure_mgmt_resource_version
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also show azure-mgmt-resource version because some packages will install Track 1 SDKs, causing conflict with Azure CLI.

versions = {}
# Add msal version
try:
from msal import __version__ as msal_version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would work!

By the way, do you consider also printing MSAL EX? :-)

I'm still providing an approval for this part. Other Azure CLI teammates please help review the rest of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, do you consider also printing MSAL EX? :-)

Let's only add msal for now, since the list can go on and on.

@jiasli jiasli self-assigned this Dec 17, 2021
@jiasli jiasli marked this pull request as ready for review December 17, 2021 02:41
@yonzhan yonzhan added this to the Jan 2022 (2022-02-01) milestone Dec 22, 2021
@yonzhan
Copy link
Collaborator

yonzhan commented Dec 22, 2021

Packaging

@jiasli
Copy link
Member Author

jiasli commented Dec 24, 2021

Another example demonstrating we should show azure-mgmt-resource: #20820

@jiasli jiasli changed the title {Packaging} Show msal and azure-mgmt-resource versions {Feedback} Show msal and azure-mgmt-resource versions Dec 24, 2021
@jiasli jiasli merged commit 103c4e9 into Azure:dev Dec 27, 2021
@jiasli jiasli deleted the version branch December 27, 2021 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants