Skip to content

Collect Authentication Telemetry #27560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 25, 2025
Merged

Collect Authentication Telemetry #27560

merged 14 commits into from
Apr 25, 2025

Conversation

msJinLei
Copy link
Contributor

@msJinLei msJinLei commented Apr 14, 2025

Description

The purpose of the PR is to send new property to Azure PowerShell telemetry to collection information of authentication

  • The following figure is what new properties look like
image
  • The details of auth-info-secondary
    [{"TokenCredentialName":"SharedTokenCacheCredential","AuthenticationSuccess":true},{"TokenCredentialName":"SharedTokenCacheCredential","AuthenticationSuccess":false},{"TokenCredentialName":"SharedTokenCacheCredential","AuthenticationSuccess":false},{"TokenCredentialName":"SharedTokenCacheCredential","AuthenticationSuccess":false},{"TokenCredentialName":"SharedTokenCacheCredential","AuthenticationSuccess":true},{"TokenCredentialName":"SharedTokenCacheCredential","AuthenticationSuccess":false},{"TokenCredentialName":"SharedTokenCacheCredential","AuthenticationSuccess":false}]

  • API Change
    Add Interface to Send Auth Info to Telemetry azure-powershell-common#421

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • For SDK-based development mode, update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • For autorest-based development mode, include the changelog in the PR description.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

@msJinLei msJinLei added this to the Az 13.5.0 (05/06/2025) milestone Apr 14, 2025
@msJinLei msJinLei force-pushed the jinlei/includeLatestCommon branch from f2c75d6 to e90adbf Compare April 22, 2025 20:50
@msJinLei msJinLei marked this pull request as ready for review April 23, 2025 07:52
@msJinLei msJinLei requested review from NoriZC and Copilot April 23, 2025 08:33
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces authentication telemetry collection by adding and passing a new CmdletContext property throughout the authentication workflow. Key changes include:

  • Adding a new public ICmdletContext property in RMProfileClient and updating authentication methods to use it.
  • Updating various components and test files to register and pass the _cmdletContext as part of authentication requests.
  • Modifying methods in ContextAdapter and others to support the additional telemetry context.

Reviewed Changes

Copilot reviewed 52 out of 52 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Accounts/Accounts/Models/RMProfileClient.cs Added ICmdletContext property and updated Authenticate method.
src/Accounts/Accounts/Environment/GetAzureRMEnvironment.cs Instantiated RMProfileClient with new CmdletContext property.
src/Accounts/Accounts/Default/SetAzureRMDefault.cs Updated GetServiceClientCredentials call to include _cmdletContext.
src/Accounts/Accounts/Default/GetAzureRmDefault.cs Updated GetServiceClientCredentials call to include _cmdletContext.
src/Accounts/Accounts/Context/GetAzureRMContext.cs Modified RefreshContextsFromCache to pass _cmdletContext.
src/Accounts/Accounts/CommonModule/EnvironmentExtensions.cs Minor update to use default literal for improved readability.
src/Accounts/Accounts/CommonModule/ContextAdapter.cs Extended authentication helper methods to accept and pass cmdletContext.
src/Accounts/Accounts/Common/AzureContextModificationCmdlet.cs Updated object initialization to include CmdletContext property.
Test Files Updated tests to register AuthenticationTelemetry component.
src/Accounts/Accounts/ChangeLog.md Updated changelog to document telemetry changes.

@msJinLei msJinLei requested a review from dolauli April 24, 2025 02:40
@msJinLei msJinLei requested review from dolauli, NoriZC and Copilot April 25, 2025 04:31
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds telemetry for authentication by introducing a new property and passing through a cmdlet context parameter in various client initializations. Key changes include:

  • Updating RMProfileClient and related methods to accept a new CmdletContext.
  • Modifying service client initialization calls to pass the _cmdletContext.
  • Registering an AuthenticationTelemetry component in multiple modules and test setups.

Reviewed Changes

Copilot reviewed 50 out of 50 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Accounts/Accounts/Subscription/GetAzureRMSubscription.cs Updated RMProfileClient initialization to include WarningLog and CmdletContext, but contains a redundant WarningLog assignment.
src/Accounts/Accounts/Rest/InvokeAzRestMethodCommand.cs Modified client creation calls to pass _cmdletContext.
src/Accounts/Accounts/Models/RMProfileClient.cs Added CmdletContext property and updated Authenticate call with new optional parameters.
src/Accounts/Accounts/Environment/GetAzureRMEnvironment.cs Updated RMProfileClient initialization to include CmdletContext.
src/Accounts/Accounts/Default/SetAzureRMDefault.cs, GetAzureRmDefault.cs Updated GetServiceClientCredentials calls to pass _cmdletContext.
src/Accounts/Accounts/Context/GetAzureRMContext.cs Updated RefreshContextsFromCache to pass _cmdletContext.
src/Accounts/Accounts/Common/AzureContextModificationCmdlet.cs Updated RMProfileClient initialization to include CmdletContext.
Remaining files (ChangeLog.md, ConnectAzureRmAccount.cs and test files) Integrated AuthenticationTelemetry registration and updated test setups consistently.
Comments suppressed due to low confidence (1)

src/Accounts/Accounts/Subscription/GetAzureRMSubscription.cs:67

  • The WarningLog property is being assigned twice; please remove the redundant assignment on line 67 to prevent potential confusion or unexpected behavior.
_client.WarningLog = (s) => WriteWarning(s);

@dolauli dolauli self-assigned this Apr 25, 2025
@dolauli dolauli merged commit 797bfc2 into main Apr 25, 2025
13 checks passed
@dolauli dolauli deleted the jinlei/includeLatestCommon branch April 25, 2025 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants