[Identity] Update AzurePowerShellCredential script#41675
Merged
pvaneck merged 3 commits intoAzure:mainfrom Jun 25, 2025
Merged
Conversation
- Only add the `-AsSecureString` argument when available and needed. This argument is no longer needed for `Az.Accounts` versions 5.0.0 and above. - Update secure string parsing logic to allow it to work if a user is using Windows PowerShell instead of PowerShell 7+. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
bca9b0c to
83c8f09
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refines the AzurePowerShellCredential helper by restricting the -AsSecureString flag to Az.Accounts versions 2.17.0–<5.0.0 and adds a fallback path for parsing SecureString tokens on Windows PowerShell (<7). It also updates the changelog to document this bug fix.
- Limit
-AsSecureStringusage to the intended Az.Accounts version range. - Introduce SecureString-to-plaintext conversion logic for PSVersion < 7.
- Add a changelog entry for the Windows PowerShell compatibility fix.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/identity/azure-identity/azure/identity/_credentials/azure_powershell.py | Adjusted version condition and added branch for SecureString parsing |
| sdk/identity/azure-identity/CHANGELOG.md | Inserted bug fix entry for Windows PowerShell SecureString support |
Comments suppressed due to low confidence (2)
sdk/identity/azure-identity/azure/identity/_credentials/azure_powershell.py:51
- This new branch for Windows PowerShell (<7) parsing logic should be covered by automated tests to ensure both PS 7+ and Windows PowerShell behaviors are validated.
if ($PSVersionTable.PSVersion.Major -lt 7) {{
sdk/identity/azure-identity/CHANGELOG.md:11
- Please confirm that
#41675matches this PR number, and consider also linking the original issue (#41508) in the changelog entry for clearer tracking.
- Fixed an issue with `AzurePowerShellCredential` not working correctly for users still using older versions of PowerShell (e.g., Windows PowerShell 5.1) where `-AsPlainText` is not supported in the `ConvertFrom-SecureString` cmdlet. ([#41675](https://github.com/Azure/azure-sdk-for-python/pull/41675))
sdk/identity/azure-identity/azure/identity/_credentials/azure_powershell.py
Show resolved
Hide resolved
sdk/identity/azure-identity/azure/identity/_credentials/azure_powershell.py
Outdated
Show resolved
Hide resolved
xiangyan99
approved these changes
Jun 23, 2025
…powershell.py Co-authored-by: Minh-Anh Phan <111523473+minhanh-phan@users.noreply.github.com>
scottaddie
reviewed
Jun 24, 2025
sdk/identity/azure-identity/azure/identity/_credentials/azure_powershell.py
Show resolved
Hide resolved
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
minhanh-phan
approved these changes
Jun 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-AsSecureStringargument when available and needed. This argument is no longer needed forAz.Accountsversions 5.0.0 and above.Closes: #41508