Skip to content

Conversation

@srcharug
Copy link
Contributor

@srcharug srcharug commented Jan 20, 2026

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

  • SHOULD update ChangeLog.md file(s) appropriately
    • 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.
    • 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

@azure-client-tools-bot-prd
Copy link

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

Copy link
Contributor

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 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

Comment on lines +392 to +395
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;
Copy link

Copilot AI Jan 20, 2026

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.

Suggested change
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 uses AI. Check for mistakes.
Comment on lines +390 to +396
#$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;

Copy link

Copilot AI Jan 20, 2026

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.

Suggested change
#$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 uses AI. Check for mistakes.
Comment on lines +289 to +291
# $newVmssName = 'vmss2' + $rgname;
# $convertResult = Convert-AzAvailabilitySet -ResourceGroupName $rgname -Name $asetName -VirtualMachineScaleSetName $newVmssName;
# Assert-NotNull $convertResult;
Copy link

Copilot AI Jan 20, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +240 to +300
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
}
}
Copy link

Copilot AI Jan 20, 2026

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.

Copilot uses AI. Check for mistakes.
<#
.SYNOPSIS
Test Availability Set Convert to VMSS Flex
Note: This test requires the subscription to be enabled for the feature flag Microsoft.Compute/ConvertToVmssFlex
Copy link

Copilot AI Jan 20, 2026

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
$convertResult = Convert-AzAvailabilitySet -ResourceGroupName $rgname -Name $asetName -VirtualMachineScaleSetName $newVmssName;
Assert-NotNull $convertResult;

Write-Host "Availability Set Migration cmdlets test completed successfully";
Copy link

Copilot AI Jan 20, 2026

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.

Suggested change
Write-Host "Availability Set Migration cmdlets test completed successfully";
Write-Host "Availability Set Convert cmdlet test completed successfully";

Copilot uses AI. Check for mistakes.
@isra-fel
Copy link
Member

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

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.

5 participants