Skip to content
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

[Az.Accounts] Remove duplicated code copied from Azure.Identity #25733

Merged
merged 5 commits into from
Aug 5, 2024

Conversation

YanaXu
Copy link
Contributor

@YanaXu YanaXu commented Aug 2, 2024

This PR is going to remove duplicated code copied from Azure.Identity.
Generally, the folder src/Accounts/Authentication/Identity will removed. The files are copied from Azure.Identity and Azure.Core.
One file src/Accounts/Authentication/Identity/Core/TaskExtensions.cs is not removed but moved to folder src\Accounts\Authentication\KeyStore because it's internal and only used by src\Accounts\Authentication\KeyStore\AsyncLockWithValue.cs.
The test result of this PR shows, after Connect-AzAccount with SP+OIDC, the instance of AzureSession has no updates.
And this PR will fix #22628.

Description

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

azure-client-tools-bot-prd bot commented Aug 2, 2024

⚠️Az.Accounts
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Breaking Change Check
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Signature Check
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Help File Existence Check
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️File Change Check
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
⚠️UX Metadata Check
⚠️PowerShell Core - Windows
Type Module ResourceType SubResourceType Command Description
⚠️ Az.Accounts Microsoft.Subscription subscriptions Get-AzSubscription The path /subscriptions/{subscriptionId} doesn't contains the right resource tpye: Microsoft.Subscription
⚠️Windows PowerShell - Windows
Type Module ResourceType SubResourceType Command Description
⚠️ Az.Accounts Microsoft.Subscription subscriptions Get-AzSubscription The path /subscriptions/{subscriptionId} doesn't contains the right resource tpye: Microsoft.Subscription
️✔️Test
️✔️ - Linux
️✔️ - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Aks
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️ - Linux
️✔️ - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.ApplicationInsights
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️ - Linux
️✔️ - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Compute
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️ - Linux
️✔️ - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Functions
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️ - Linux
️✔️ - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
⚠️Az.KeyVault
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
⚠️Test
⚠️ - Linux
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 22.09 % Test coverage for the module cannot be lower than 50%.
⚠️ - MacOS
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 22.09% Test coverage for the module cannot be lower than 50%.
⚠️PowerShell Core - Windows
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 22.09% Test coverage for the module cannot be lower than 50%.
⚠️Windows PowerShell - Windows
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 22.09% Test coverage for the module cannot be lower than 50%.
️✔️Az.KubernetesConfiguration
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️ - Linux
️✔️ - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.ManagedServiceIdentity
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Monitor
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Network
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️ - Linux
️✔️ - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.OperationalInsights
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.PostgreSql
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️ - Linux
️✔️ - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.PrivateDns
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
⚠️Az.Purview
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
⚠️Test
⚠️ - Linux
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 8.70 % Test coverage for the module cannot be lower than 50%.
⚠️ - MacOS
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 8.70% Test coverage for the module cannot be lower than 50%.
⚠️PowerShell Core - Windows
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 8.70% Test coverage for the module cannot be lower than 50%.
⚠️Windows PowerShell - Windows
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 8.70% Test coverage for the module cannot be lower than 50%.
️✔️Az.Resources
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️ - Linux
️✔️ - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Sql
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
⚠️Az.Storage
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
⚠️Test
⚠️ - Linux
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 41.76 % Test coverage for the module cannot be lower than 50%.
⚠️ - MacOS
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 41.76% Test coverage for the module cannot be lower than 50%.
⚠️PowerShell Core - Windows
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 41.76% Test coverage for the module cannot be lower than 50%.
⚠️Windows PowerShell - Windows
Type Title Current Coverage Description
⚠️ Test Coverage Less Than 50% 41.76% Test coverage for the module cannot be lower than 50%.
️✔️Az.Websites
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️ - Linux
️✔️ - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows

@msJinLei
Copy link
Contributor

msJinLei commented Aug 5, 2024

@YanaXu could you check if src/Accounts/Authentication/Identity/Core/TaskExtensions.cs is only used by src/Accounts/Authentication/KeyStore/AsyncLockWithValue.cs?

@isra-fel
Copy link
Member

isra-fel commented Aug 5, 2024

LGTM
If we are not removing all dup code, let's keep src/Accounts/Authentication/Identity/README.md and add a note to it.

@YanaXu
Copy link
Contributor Author

YanaXu commented Aug 5, 2024

@YanaXu could you check if src/Accounts/Authentication/Identity/Core/TaskExtensions.cs is only used by src/Accounts/Authentication/KeyStore/AsyncLockWithValue.cs?

Yes.
If we seach for the usage of "TaskExtensions" class, there are no results.
If we remove Authentication/Identity/Core/TaskExtensions.cs, and run dotnet build under src\Accounts, only src\Accounts\Authentication\KeyStore\AsyncLockWithValue.cs reports an error.
If we search "Microsoft.Azure.PowerShell.Authenticators.Identity.Core", there is only src\Accounts\Authentication\KeyStore\AsyncLockWithValue.cs.
It's an internal class. So the only usage must be src\Accounts\Authentication\KeyStore\AsyncLockWithValue.cs.

@msJinLei
Copy link
Contributor

msJinLei commented Aug 5, 2024

@YanaXu could you check if src/Accounts/Authentication/Identity/Core/TaskExtensions.cs is only used by src/Accounts/Authentication/KeyStore/AsyncLockWithValue.cs?

Yes. If we seach for the usage of "TaskExtensions" class, there are no results. If we remove Authentication/Identity/Core/TaskExtensions.cs, and run dotnet build under src\Accounts, only src\Accounts\Authentication\KeyStore\AsyncLockWithValue.cs reports an error. If we search "Microsoft.Azure.PowerShell.Authenticators.Identity.Core", there is only src\Accounts\Authentication\KeyStore\AsyncLockWithValue.cs. It's an internal class. So the only usage must be src\Accounts\Authentication\KeyStore\AsyncLockWithValue.cs.

Please move TaskExtensions to src\Accounts\Authentication\KeyStore to make it clear. Thanks
Others are good to me.

@YanaXu
Copy link
Contributor Author

YanaXu commented Aug 5, 2024

Reproduce the issue #22628.

PS /> Install-Module -Name Az.Accounts -Repository PSGallery -Force
PS /> Import-Module Az.Accounts
PS /> Disable-AzContextAutosave -Scope Process

Mode             : Process
ContextDirectory : None
ContextFile      : None
CacheDirectory   : None
CacheFile        : None
KeyStoreFile     : None
Settings         : {[InstallationId, ********-****-****-****-************]}

PS /> Connect-AzAccount -ServicePrincipal -ApplicationId "********-****-****-****-************" -Tenant "********-****-****-****-************" -SubscriptionId "********-****-****-****-************" -FederatedToken $idToken
Connect-AzAccount: ClientAssertionCredential authentication failed: Persistence check failed. Inspect inner exception for details
Could not find tenant id for provided tenant domain '********-****-****-****-************'.

Test with this PR fix.

PS /> Import-Module /test/Az.Accounts/Az.Accounts.psd1
PS /> Disable-AzContextAutosave -Scope Process

Mode             : Process
ContextDirectory : None
ContextFile      : None
CacheDirectory   : None
CacheFile        : None
KeyStoreFile     : None
Settings         : {[InstallationId, ********-****-****-****-************]}

PS /> Connect-AzAccount -ServicePrincipal -ApplicationId "********-****-****-****-************" -Tenant "********-****-****-****-************" -SubscriptionId "********-****-****-****-************" -FederatedToken $idToken

Subscription name        Tenant
-----------------        ------
*******                  ********-****-****-****-************

Polish change log
@YanaXu YanaXu merged commit 9869090 into main Aug 5, 2024
12 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 5, 2024
* use Azure.Identity

* update README.md

* update ChangeLog.md

* move TaskExtensions.cs to src/Accounts/Authentication/KeyStore

* Update ChangeLog.md

Polish change log

---------

Co-authored-by: Jin Lei <[email protected]>
@YanaXu YanaXu deleted the yanxu/accounts branch August 5, 2024 07:50
VeryEarly added a commit that referenced this pull request Aug 6, 2024
…) (#25764)

* use Azure.Identity

* update README.md

* update ChangeLog.md

* move TaskExtensions.cs to src/Accounts/Authentication/KeyStore

* Update ChangeLog.md

Polish change log

---------

Co-authored-by: Yan Xu <[email protected]>
Co-authored-by: Jin Lei <[email protected]>
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.

Azure OIDC login fails in Github Actions
3 participants