-
Couldn't load subscription status.
- Fork 4.1k
migrate LoadTesting to autorest v4 #28284
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
base: main
Are you sure you want to change the base?
Conversation
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
8e2e91f to
6b1ebc1
Compare
|
To the author of the pull request, |
There was a problem hiding this 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 migrates the LoadTesting module from AutoRest v3 to AutoRest v4, introducing significant changes to the API interface and parameter handling. The migration simplifies managed identity configuration by replacing hashtable-based user identity assignment with string arrays and introduces system-assigned identity toggle parameters.
Key changes include:
- Updated parameter interface for managed identity operations with new
EnableSystemAssignedIdentityandUserAssignedIdentityparameters - Generated new parameter sets for JSON file and string inputs across all cmdlets
- Updated documentation and examples to reflect the new parameter syntax
Reviewed Changes
Copilot reviewed 33 out of 34 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
tools/StaticAnalysis/Exceptions/Az.LoadTesting/BreakingChangeIssues.csv |
Documents breaking changes from v3 to v4 migration including parameter removals and type changes |
src/LoadTesting/LoadTesting/help/*.md |
Updated help documentation with new parameter sets and simplified identity management syntax |
src/LoadTesting/LoadTesting/ChangeLog.md |
Documents the AutoRest v4 upgrade and breaking changes to identity parameters |
src/LoadTesting/LoadTesting.Autorest/custom/*.ps1 |
Updated cmdlet implementations with new identity parameter handling logic |
src/LoadTesting/LoadTesting.Autorest/test/* |
Updated test files with new parameter syntax and test environment configurations |
src/LoadTesting/LoadTesting.Autorest/README.md |
Updated AutoRest configuration to disable identity type transforms and add new directives |
|
|
||
| # calculate IdentityType | ||
| $supportsSystemAssignedIdentity = $EnableSystemAssignedIdentity -or (($null -eq $EnableSystemAssignedIdentity) -and ($loadTestingObject.IdentityType.Contains('SystemAssigned'))) | ||
| $supportsUserAssignedIdentity = ($PSBoundParameters.ContainsKey('UserAssignedIdentity') -and $UserAssignedIdentity.Length -gt 0) -or ((-not $PSBoundParameters.ContainsKey('UserAssignedIdentity')) -and ($loadTestingObject.IdentityType.Contains('UserAssigned'))); |
Copilot
AI
Aug 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This complex boolean logic should be simplified for better readability. Consider breaking it into multiple variables or using helper functions to make the condition more understandable.
| $supportsUserAssignedIdentity = ($PSBoundParameters.ContainsKey('UserAssignedIdentity') -and $UserAssignedIdentity.Length -gt 0) -or ((-not $PSBoundParameters.ContainsKey('UserAssignedIdentity')) -and ($loadTestingObject.IdentityType.Contains('UserAssigned'))); | |
| $hasUserAssignedIdentityParameter = $PSBoundParameters.ContainsKey('UserAssignedIdentity') | |
| $userAssignedIdentityParameterNotEmpty = $hasUserAssignedIdentityParameter -and ($UserAssignedIdentity.Length -gt 0) | |
| $userAssignedIdentityParameterMissing = -not $hasUserAssignedIdentityParameter | |
| $objectHasUserAssignedIdentity = $loadTestingObject.IdentityType.Contains('UserAssigned') | |
| $supportsUserAssignedIdentity = $userAssignedIdentityParameterNotEmpty -or ($userAssignedIdentityParameterMissing -and $objectHasUserAssignedIdentity) | |
| $supportsUserAssignedIdentity = $PSBoundParameters.ContainsKey("UserAssignedIdentity") -and $UserAssignedIdentity.Length -gt 0 | ||
|
|
||
| # calculate IdentityType | ||
| if (($supportsSystemAssignedIdentity -and $supportsUserAssignedIdentity)) { |
Copilot
AI
Aug 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The parentheses around the first condition are unnecessary and create inconsistent formatting with the subsequent else-if conditions.
| if (($supportsSystemAssignedIdentity -and $supportsUserAssignedIdentity)) { | |
| if ($supportsSystemAssignedIdentity -and $supportsUserAssignedIdentity) { |
| # calculate IdentityType | ||
| $supportsSystemAssignedIdentity = $EnableSystemAssignedIdentity -or (($null -eq $EnableSystemAssignedIdentity) -and ($loadTestingObject.IdentityType.Contains('SystemAssigned'))) | ||
| $supportsUserAssignedIdentity = ($PSBoundParameters.ContainsKey('UserAssignedIdentity') -and $UserAssignedIdentity.Length -gt 0) -or ((-not $PSBoundParameters.ContainsKey('UserAssignedIdentity')) -and ($loadTestingObject.IdentityType.Contains('UserAssigned'))); | ||
| if (($supportsSystemAssignedIdentity -and $supportsUserAssignedIdentity)) { |
Copilot
AI
Aug 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The parentheses around the first condition are unnecessary and create inconsistent formatting with the subsequent else-if conditions.
| if (($supportsSystemAssignedIdentity -and $supportsUserAssignedIdentity)) { | |
| if ($supportsSystemAssignedIdentity -and $supportsUserAssignedIdentity) { |
| ### Example 2: Update an Azure Load Testing resource to use System-Assigned identity for CMK encryption | ||
| ```powershell | ||
| Update-AzLoad -Name sampleres -ResourceGroupName sample-rg -IdentityType "SystemAssigned" -EncryptionIdentity "SystemAssigned" -EncryptionKey "https://sample-akv.vault.azure.net/keys/cmk/2d1ccd5c50234ea2a0858fe148b69cde" | ||
| Update-AzLoad -Name sampleres -ResourceGroupName sample-rg -EnableSystemAssignedIdentity $true -EncryptionIdentity "SystemAssigned" -EncryptionKey "https://sample-akv.vault.azure.net/keys/cmk/2d1ccd5c50234ea2a0858fe148b69cde" |
Copilot
AI
Aug 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using $true with the EnableSystemAssignedIdentity parameter is redundant since it's a Boolean parameter. The parameter should be used as a switch: -EnableSystemAssignedIdentity instead of -EnableSystemAssignedIdentity $true.
| Update-AzLoad -Name sampleres -ResourceGroupName sample-rg -EnableSystemAssignedIdentity $true -EncryptionIdentity "SystemAssigned" -EncryptionKey "https://sample-akv.vault.azure.net/keys/cmk/2d1ccd5c50234ea2a0858fe148b69cde" | |
| Update-AzLoad -Name sampleres -ResourceGroupName sample-rg -EnableSystemAssignedIdentity -EncryptionIdentity "SystemAssigned" -EncryptionKey "https://sample-akv.vault.azure.net/keys/cmk/2d1ccd5c50234ea2a0858fe148b69cde" |
| $loadTestingObject.IdentityUserAssignedIdentity.Keys | ForEach-Object { | ||
| if (-NOT($_ -in $UserAssignedIdentity)) { | ||
| $PSBoundParameters.IdentityUserAssignedIdentity.Add($_, $null) |
Copilot
AI
Aug 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a more efficient approach than piping to ForEach-Object for iterating over dictionary keys, such as using a foreach loop which would be faster for this operation.
| $loadTestingObject.IdentityUserAssignedIdentity.Keys | ForEach-Object { | |
| if (-NOT($_ -in $UserAssignedIdentity)) { | |
| $PSBoundParameters.IdentityUserAssignedIdentity.Add($_, $null) | |
| foreach ($key in $loadTestingObject.IdentityUserAssignedIdentity.Keys) { | |
| if (-NOT($key -in $UserAssignedIdentity)) { | |
| $PSBoundParameters.IdentityUserAssignedIdentity.Add($key, $null) |
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
eac4f6f to
0ea9d89
Compare
0ea9d89 to
5c8cfbf
Compare
Description
Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.mdand reviewed the following information:ChangeLog.mdfile(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.## Upcoming Releaseheader in the past tense.ChangeLog.mdif no new release is required, such as fixing test case only.