-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Migration ps #29085
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?
Migration ps #29085
Conversation
This agent will create a Powershell PR based on the issue described. It will write tests, make code changes and add changelog.
Update agent name and description for Powershell PR
Agent instructions
Add Compute PR agent instructions
Co-authored-by: haagha <64601174+haagha@users.noreply.github.com>
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
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 pull request adds five new cmdlets to enable migration of Availability Sets to Flexible Virtual Machine Scale Sets (VMSS Flex) in Azure PowerShell Compute module. This feature is in public preview and requires the subscription to be enabled for the feature flag Microsoft.Compute/MigrateToVmssFlex.
Changes:
- Added five new cmdlets: Test-AzAvailabilitySetMigration, Start-AzAvailabilitySetMigration, Stop-AzAvailabilitySetMigration, Convert-AzAvailabilitySet, and Move-AzVirtualMachineToVmss
- Updated module manifest to export the new cmdlets
- Added PowerShell and C# test scenarios
- Updated ChangeLog.md with feature description
Reviewed changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Test-AzAvailabilitySetMigration.md | Help documentation for validating Availability Set migration to VMSS |
| Stop-AzAvailabilitySetMigration.md | Help documentation for canceling migration operations |
| Start-AzAvailabilitySetMigration.md | Help documentation for starting Availability Set migration |
| Move-AzVirtualMachineToVmss.md | Help documentation for migrating individual VMs to VMSS |
| Convert-AzAvailabilitySet.md | Help documentation for converting Availability Set to new VMSS |
| MoveAzureVMToVmssCommand.cs | C# implementation of Move-AzVirtualMachineToVmss cmdlet |
| ChangeLog.md | Updated with descriptions of new cmdlets |
| Az.Compute.psd1 | Module manifest updated to export new cmdlets |
| TestAzureAvailabilitySetMigrationCommand.cs | C# implementation of Test-AzAvailabilitySetMigration cmdlet |
| StopAzureAvailabilitySetMigrationCommand.cs | C# implementation of Stop-AzAvailabilitySetMigration cmdlet |
| StartAzureAvailabilitySetMigrationCommand.cs | C# implementation of Start-AzAvailabilitySetMigration cmdlet |
| ConvertAzureAvailabilitySetCommand.cs | C# implementation of Convert-AzAvailabilitySet cmdlet |
| AvailabilitySetTests.ps1 | PowerShell test scenarios for migration cmdlets |
| AvailabilitySetTests.cs | C# test runner for migration tests |
| computePR.agent.md | New agent documentation file for Compute PR workflows |
| Assert-AreEqual $p.StorageProfile.ImageReference.Offer $imgRef.Offer; | ||
| Assert-AreEqual $p.StorageProfile.ImageReference.Publisher $imgRef.PublisherName; | ||
| Assert-AreEqual $p.StorageProfile.ImageReference.Sku $imgRef.Skus; | ||
| Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version; |
Copilot
AI
Jan 20, 2026
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.
The variables $p and $imgRef are not defined in this function. These assertions reference undefined variables and will fail when the test runs. The assertions on lines 392-395 should either be removed if they're not needed, or the code should be updated to properly capture the VM configuration after setting the source image.
| Assert-AreEqual $p.StorageProfile.ImageReference.Offer $imgRef.Offer; | |
| Assert-AreEqual $p.StorageProfile.ImageReference.Publisher $imgRef.PublisherName; | |
| Assert-AreEqual $p.StorageProfile.ImageReference.Sku $imgRef.Skus; | |
| Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version; |
| #$vmConfig = ($imgRef | Set-AzVMSourceImage -VM $vmConfig); | ||
|
|
||
| Assert-AreEqual $p.StorageProfile.ImageReference.Offer $imgRef.Offer; | ||
| Assert-AreEqual $p.StorageProfile.ImageReference.Publisher $imgRef.PublisherName; | ||
| Assert-AreEqual $p.StorageProfile.ImageReference.Sku $imgRef.Skus; | ||
| Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version; | ||
|
|
Copilot
AI
Jan 20, 2026
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 commented-out line and the assertion code below it (lines 392-395) suggest incomplete or leftover code from development. The commented line should either be removed or properly integrated into the test logic.
| #$vmConfig = ($imgRef | Set-AzVMSourceImage -VM $vmConfig); | |
| Assert-AreEqual $p.StorageProfile.ImageReference.Offer $imgRef.Offer; | |
| Assert-AreEqual $p.StorageProfile.ImageReference.Publisher $imgRef.PublisherName; | |
| Assert-AreEqual $p.StorageProfile.ImageReference.Sku $imgRef.Skus; | |
| Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version; | |
| # $newVmssName = 'vmss2' + $rgname; | ||
| # $convertResult = Convert-AzAvailabilitySet -ResourceGroupName $rgname -Name $asetName -VirtualMachineScaleSetName $newVmssName; | ||
| # Assert-NotNull $convertResult; |
Copilot
AI
Jan 20, 2026
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.
The test for Convert-AzAvailabilitySet cmdlet is commented out (lines 289-291). This appears to be a significant piece of test coverage that should be enabled to properly validate the Convert-AzAvailabilitySet cmdlet functionality.
| function Test-AvailabilitySetMigration | ||
| { | ||
| param ($loc) | ||
| # Setup | ||
| $rgname = Get-ComputeTestResourceName | ||
|
|
||
| try | ||
| { | ||
| # Common | ||
| if ($loc -eq $null) | ||
| { | ||
| $loc = Get-ComputeVMLocation; | ||
| } | ||
| New-AzResourceGroup -Name $rgname -Location $loc -Force; | ||
|
|
||
| # Create Availability Set | ||
| $asetName = 'aset' + $rgname; | ||
| New-AzAvailabilitySet -ResourceGroupName $rgname -Name $asetName -Location $loc -Sku 'Aligned' -PlatformFaultDomainCount 2 -PlatformUpdateDomainCount 7; | ||
| $aset = Get-AzAvailabilitySet -ResourceGroupName $rgname -Name $asetName; | ||
| Assert-NotNull $aset; | ||
|
|
||
| # Create a VM in the Availability Set | ||
| $vmname = 'vm' + $rgname; | ||
| $vm = New-TestVmInAvailabilitySet -ResourceGroupName $rgname -Location $loc -AvailabilitySetId $aset.Id -VmName $vmname; | ||
| $a = $vm | Out-String; | ||
| Write-Verbose("Get-AzVM output:"); | ||
| Write-Verbose($a); | ||
| Assert-NotNull $a | ||
|
|
||
| # Create a Flexible VMSS for migration target | ||
| $vmssName = 'vmss' + $rgname; | ||
| $vmssConfig = New-AzVmssConfig -Location $loc -OrchestrationMode 'Flexible' -PlatformFaultDomainCount 2 -SinglePlacementGroup $false; | ||
| $vmss = New-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName -VirtualMachineScaleSet $vmssConfig; | ||
| Assert-NotNull $vmss; | ||
| $vmssId = $vmss.Id; | ||
|
|
||
| # Test Validate Migration cmdlet | ||
| $validateResult = Test-AzAvailabilitySetMigration -ResourceGroupName $rgname -Name $asetName -VirtualMachineScaleSetFlexibleId $vmssId; | ||
| Assert-NotNull $validateResult; | ||
|
|
||
| # Test StartMigration cmdlet | ||
| $migrationResult = Start-AzAvailabilitySetMigration -ResourceGroupName $rgname -Name $asetName -VirtualMachineScaleSetFlexibleId $vmssId; | ||
| Assert-NotNull $migrationResult; | ||
|
|
||
| # Migrate VM to VMSS Flex | ||
| $migratedVM = Move-AzVirtualMachineToVmss -Id $vm.Id | ||
| Assert-NotNull $migratedVM; | ||
|
|
||
| # Test Convert cmdlet (creates a new VMSS) | ||
| # $newVmssName = 'vmss2' + $rgname; | ||
| # $convertResult = Convert-AzAvailabilitySet -ResourceGroupName $rgname -Name $asetName -VirtualMachineScaleSetName $newVmssName; | ||
| # Assert-NotNull $convertResult; | ||
|
|
||
| Write-Host "Availability Set Migration cmdlets test completed successfully"; | ||
| } | ||
| finally | ||
| { | ||
| # Cleanup | ||
| Clean-ResourceGroup $rgname | ||
| } | ||
| } |
Copilot
AI
Jan 20, 2026
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.
The test function Test-AvailabilitySetMigration does not include test coverage for the Stop-AzAvailabilitySetMigration cmdlet. This cmdlet is part of the migration workflow and should be tested to ensure it can properly cancel migration operations.
| <# | ||
| .SYNOPSIS | ||
| Test Availability Set Convert to VMSS Flex | ||
| Note: This test requires the subscription to be enabled for the feature flag Microsoft.Compute/ConvertToVmssFlex |
Copilot
AI
Jan 20, 2026
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.
The comment mentions the feature flag "Microsoft.Compute/ConvertToVmssFlex", but based on the PR description and other test comments, the feature flag should be "Microsoft.Compute/MigrateToVmssFlex". This inconsistency could cause confusion about what feature flag is required for testing.
| Note: This test requires the subscription to be enabled for the feature flag Microsoft.Compute/ConvertToVmssFlex | |
| Note: This test requires the subscription to be enabled for the feature flag Microsoft.Compute/MigrateToVmssFlex |
| $convertResult = Convert-AzAvailabilitySet -ResourceGroupName $rgname -Name $asetName -VirtualMachineScaleSetName $newVmssName; | ||
| Assert-NotNull $convertResult; | ||
|
|
||
| Write-Host "Availability Set Migration cmdlets test completed successfully"; |
Copilot
AI
Jan 20, 2026
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.
The success message says "Availability Set Migration cmdlets test completed successfully" but this is the Test-AvailabilitySetConvert function, which tests the Convert cmdlet specifically. The message should be "Availability Set Convert cmdlet test completed successfully" to accurately reflect what was tested.
| Write-Host "Availability Set Migration cmdlets test completed successfully"; | |
| Write-Host "Availability Set Convert cmdlet test completed successfully"; |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Description
Added Migration and Convert APIs for AvailabilitySets. Added UTs to test the same.
Migrate AvailabilitySet -https://learn.microsoft.com/en-us/cli/azure/vm/availability-set?view=azure-cli-latest#az-vm-availability-set-start-migration-to-vmss
Convert AvailabilitySet - https://learn.microsoft.com/en-us/cli/azure/vm/availability-set?view=azure-cli-latest#az-vm-availability-set-convert-to-vmss
VM migration - https://learn.microsoft.com/en-us/cli/azure/vm?view=azure-cli-latest#az-vm-migrate-to-vmss
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.