From 7654cb2457ff5357b106cfcaed08d51ce13f1fc4 Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Wed, 30 Jul 2025 10:22:59 -0700 Subject: [PATCH 1/7] Small bug fix --- .../custom/New-AzMigrateLocalDiskMappingObject.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalDiskMappingObject.ps1 b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalDiskMappingObject.ps1 index 68e44466aab1..85b13f624613 100644 --- a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalDiskMappingObject.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalDiskMappingObject.ps1 @@ -74,9 +74,10 @@ function New-AzMigrateLocalDiskMappingObject { process { $isDynamicDisk = [System.Convert]::ToBoolean($IsDynamic) $osDisk = [System.Convert]::ToBoolean($IsOSDisk) + $hasPhysicalSectorSize = $PSBoundParameters.ContainsKey('PhysicalSectorSize') - if ($Format -eq "VHD" -and $PhysicalSectorSize -ne 512) { - throw "PhysicalSectorSize must be 512 for VHD format." + if ($Format -eq "VHD" -and $hasPhysicalSectorSize -and $PhysicalSectorSize -ne 512) { + throw "PhysicalSectorSize must be 512 for VHD format but $PhysicalSectorSize is given." } $DiskObject = [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20240901.AzLocalDiskInput]::new( From 2a269d8ba362bf6e90cbce403649eb85a59c861a Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Tue, 12 Aug 2025 17:51:50 -0700 Subject: [PATCH 2/7] Fix VHD with Gen2 for datadisk logic --- .../custom/New-AzMigrateLocalServerReplication.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 index 802ca87bee65..d68979624f80 100644 --- a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 @@ -663,9 +663,9 @@ function New-AzMigrateLocalServerReplication { # Validate DiskToInclude [PSCustomObject[]]$uniqueDisks = @() foreach ($disk in $DiskToInclude) { - # VHD is not supported in Gen2 VMs - if ($customProperties.HyperVGeneration -eq "2" -and $disk.DiskFileFormat -eq "VHD") { - throw "VHD disks are not supported in Hyper-V Generation 2 VMs. Please replace disk with id '$($disk.DiskId)' in -DiskToInclude by re-running New-AzMigrateLocalDiskMappingObject with 'VHDX' as Format." + # VHD is not supported as OS disk in Gen2 VMs + if ($customProperties.HyperVGeneration -eq "2" -and $disk.DiskFileFormat -eq "VHD" -and $disk.IsOSDisk) { + throw "VHD disks cannot be used as the OS disk of Hyper-V Generation 2 VMs. Please replace disk with id '$($disk.DiskId)' in -DiskToInclude by re-running New-AzMigrateLocalDiskMappingObject with 'VHDX' as Format." } # PhysicalSectorSize must be 512 for VHD format From 6a0826e35359076fc3a494ea792d8f5c90fef6a8 Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Tue, 12 Aug 2025 18:03:19 -0700 Subject: [PATCH 3/7] Update ChangeLog --- src/Migrate/Migrate/ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Migrate/Migrate/ChangeLog.md b/src/Migrate/Migrate/ChangeLog.md index a5c9dd5164c4..c02b755e8255 100644 --- a/src/Migrate/Migrate/ChangeLog.md +++ b/src/Migrate/Migrate/ChangeLog.md @@ -18,6 +18,8 @@ - Additional information about change #1 --> ## Upcoming Release +* Fixed bugs in `New-AzMigrateLocalDiskMappingObject` to validate for non-512 physical sector size of VHD. +* Fixed bugs in `New-AzMigrateLocalServerReplication` to validate for VHD as OS disk of Hyper-V Generation 2 VMs. ## Version 2.9.0 * Added `-OsType` as an optional parameter to command `Set-AzMigrateLocalServerReplication` to allow user-specified OS type. From 1ffdfecf86f70e0092c3747a5bb097792c2f2af3 Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Thu, 4 Sep 2025 15:25:32 -0700 Subject: [PATCH 4/7] Add id validations & bug fixes --- src/Migrate/Migrate.Autorest/README.md | 2 +- .../Get-AzMigrateLocalServerReplication.ps1 | 39 ++++--- .../custom/Helper/AzLocalCommonHelper.ps1 | 77 +++++++++++++ .../custom/Helper/AzLocalCommonSettings.ps1 | 9 ++ .../New-AzMigrateLocalServerReplication.ps1 | 102 +++++++++++------- .../Set-AzMigrateLocalServerReplication.ps1 | 29 +++-- .../New-AzMigrateLocalServerReplication.md | 4 +- src/Migrate/Migrate/ChangeLog.md | 12 ++- 8 files changed, 209 insertions(+), 65 deletions(-) diff --git a/src/Migrate/Migrate.Autorest/README.md b/src/Migrate/Migrate.Autorest/README.md index 6e2e00e70cb1..c693402481a3 100644 --- a/src/Migrate/Migrate.Autorest/README.md +++ b/src/Migrate/Migrate.Autorest/README.md @@ -54,7 +54,7 @@ input-file: - $(repo)/specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2024-01-01/service.json - $(repo)/specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/stable/2024-09-01/recoveryservicesdatareplication.json -module-version: 3.0.12 +module-version: 3.0.13 title: Migrate subject-prefix: 'Migrate' diff --git a/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 index e6bef2da869e..d6e737b4a8b5 100644 --- a/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 @@ -133,6 +133,12 @@ function Get-AzMigrateLocalServerReplication { process { Import-Module $PSScriptRoot\Helper\AzLocalCommonSettings.ps1 + Import-Module $PSScriptRoot\Helper\AZLocalCommonHelper.ps1 + + $hasTargetObjectId = $PSBoundParameters.ContainsKey('TargetObjectID') + $hasDiscoveredMachineId = $PSBoundParameters.ContainsKey('DiscoveredMachineId') + $hasResourceGroupId = $PSBoundParameters.ContainsKey('ResourceGroupID') + $hasProjectId = $PSBoundParameters.ContainsKey('ProjectID') $parameterSet = $PSCmdlet.ParameterSetName $null = $PSBoundParameters.Remove('TargetObjectID') @@ -143,12 +149,26 @@ function Get-AzMigrateLocalServerReplication { $null = $PSBoundParameters.Remove('ResourceGroupID') $null = $PSBoundParameters.Remove('ProjectID') $null = $PSBoundParameters.Remove('MachineName') + + # Validate ARM ID format from inputs + if ($hasTargetObjectId -and !(Test-AzureResourceIdFormat -Data $TargetObjectID -Format $IdFormats.ProtectedItemArmIdTemplate)) { + throw "Invalid -TargetObjectID '$TargetObjectID'. A valid protected item ARM ID should follow the format '$($IdFormats.ProtectedItemArmIdTemplate)'." + } + + if ($hasDiscoveredMachineId -and !(Test-AzureResourceIdFormat -Data $DiscoveredMachineId -Format $IdFormats.MachineArmIdTemplate)) { + throw "Invalid -DiscoveredMachineId '$DiscoveredMachineId'. A valid machine ARM ID should follow the format '$($IdFormats.MachineArmIdTemplate)'." + } + + if ($hasResourceGroupId -and !(Test-AzureResourceIdFormat -Data $ResourceGroupID -Format $IdFormats.ResourceGroupArmIdTemplate)) { + throw "Invalid -ResourceGroupID '$ResourceGroupID'. A valid resource group ARM ID should follow the format '$($IdFormats.ResourceGroupArmIdTemplate)'." + } + + if ($hasProjectId -and !(Test-AzureResourceIdFormat -Data $ProjectID -Format $IdFormats.MigrateProjectArmIdTemplate)) { + throw "Invalid -ProjectID '$ProjectID'. A valid migrate project ARM ID should follow the format '$($IdFormats.MigrateProjectArmIdTemplate)'." + } if ($parameterSet -eq 'GetBySDSID') { $machineIdArray = $DiscoveredMachineId.Split("/") - if ($machineIdArray.Length -lt 11) { - throw "Invalid machine ARM ID '$DiscoveredMachineId'" - } $siteType = $machineIdArray[7] $siteName = $machineIdArray[8] $ResourceGroupName = $machineIdArray[4] @@ -208,17 +228,8 @@ function Get-AzMigrateLocalServerReplication { # Retrieve ResourceGroupName, ProjectName if ListByID if ($parameterSet -eq 'ListByID') { $resourceGroupIdArray = $ResourceGroupID.Split('/') - if ($resourceGroupIdArray.Length -lt 5) { - throw "Invalid resource group Id '$ResourceGroupID'." - } - $ResourceGroupName = $resourceGroupIdArray[4] - $projectIdArray = $ProjectID.Split('/') - if ($projectIdArray.Length -lt 9) { - throw "Invalid migrate project Id '$ProjectID'." - } - $ProjectName = $projectIdArray[8] } @@ -255,10 +266,6 @@ function Get-AzMigrateLocalServerReplication { $TargetObjectID = $InputObject.Id } $objectIdArray = $TargetObjectID.Split("/") - if ($objectIdArray.Length -lt 11) { - throw "Invalid target object ID '$TargetObjectID'." - } - $ResourceGroupName = $objectIdArray[4] $VaultName = $objectIdArray[8] $ProtectedItemName = $objectIdArray[10] diff --git a/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonHelper.ps1 b/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonHelper.ps1 index 94154d642c7f..9605f42ef994 100644 --- a/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonHelper.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonHelper.ps1 @@ -315,4 +315,81 @@ function ValidateReplication { { Write-Warning $VmReplicationValidationMessages.OsTypeNotSupported } +} + +function Test-AzureResourceIdFormat { + [Microsoft.Azure.PowerShell.Cmdlets.Migrate.DoNotExportAttribute()] + param( + [Parameter(Mandatory = $true)] + [string] $Data, + + [Parameter(Mandatory = $true)] + [string] $Format + ) + + try { + if ([string]::IsNullOrWhiteSpace($Data)) { + return $false + } + + # Find where format string starts (after first /) + $firstTokenEnd = $Format.IndexOf("/", 1) + if ($firstTokenEnd -eq -1) { + return $false + } + + $formatPrefix = $Format.Substring(0, $firstTokenEnd) + $matchIndex = $Data.ToLower().IndexOf($formatPrefix.ToLower()) + + if ($matchIndex -eq -1) { + return $false + } + + $processData = $Data.Substring($matchIndex) + $processFormat = $Format + $tokens = @() + + $counter = 0 + while ($true) { + $markerPattern = "{$counter}" + $markerStartIndex = $processFormat.IndexOf($markerPattern) + + if ($markerStartIndex -eq -1) { + break + } + + $markerEndIndex = $processData.IndexOf("/", $markerStartIndex) + + if ($markerEndIndex -eq -1) { + $token = $processData.Substring($markerStartIndex) + if ([string]::IsNullOrWhiteSpace($token)) { + return $false + } + $tokens += $token + } + else { + $token = $processData.Substring($markerStartIndex, $markerEndIndex - $markerStartIndex) + if ([string]::IsNullOrWhiteSpace($token)) { + return $false + } + $tokens += $token + $processData = $processData.Substring($markerEndIndex) + $processFormat = $processFormat.Substring($markerStartIndex + $markerPattern.Length) + } + + $counter++ + } + + # Verify format matches with the extracted tokens + $formatWithTokens = $Format + for ($i = 0; $i -lt $tokens.Count; $i++) { + $formatWithTokens = $formatWithTokens -replace "\{$i\}", $tokens[$i] + } + + return $Data.ToLower() -like $formatWithTokens.ToLower() + } + catch + { + return $false + } } \ No newline at end of file diff --git a/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonSettings.ps1 b/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonSettings.ps1 index 08b8766a4b9b..cc1a6df7eba8 100644 --- a/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonSettings.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonSettings.ps1 @@ -121,4 +121,13 @@ $VmReplicationValidationMessages = @{ $ArcResourceBridgeValidationMessages = @{ NotRunning = "Arc Resource Bridge is offline. To continue, bring the Arc Resource Bridge online. Wait a few minutes for the status to update and retry."; NoClusters = "There are no Azure Local clusters found in the selected resource group." +} + +$IdFormats = @{ + ResourceGroupArmIdTemplate = "/subscriptions/{0}/resourceGroups/{1}" + MachineArmIdTemplate = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.OffAzure/{2}/{3}/machines/{4}" + StoragePathArmIdTemplate = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.AzureStackHCI/storageContainers/{2}" + LogicalNetworkArmIdTemplate = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.AzureStackHCI/logicalnetworks/{2}" + MigrateProjectArmIdTemplate = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Migrate/MigrateProjects/{2}" + ProtectedItemArmIdTemplate = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.DataReplication/replicationVaults/{2}/protectedItems/{3}" } \ No newline at end of file diff --git a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 index d68979624f80..4a88584c1045 100644 --- a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 @@ -86,7 +86,7 @@ function New-AzMigrateLocalServerReplication { [Parameter(Mandatory)] [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] [System.String] - # Specifies the target Resource Group Id where the migrated VM resources will reside. + # Specifies the target resource group ARM ID where the migrated VM resources will reside. ${TargetResourceGroupId}, [Parameter(Mandatory)] @@ -98,7 +98,7 @@ function New-AzMigrateLocalServerReplication { [Parameter(ParameterSetName = 'ByIdDefaultUser', Mandatory)] [Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] [System.String] - # Specifies the Operating System disk for the source server to be migrated. + # Specifies the operating system disk for the source server to be migrated. ${OSDiskID}, [Parameter(Mandatory)] @@ -181,23 +181,39 @@ function New-AzMigrateLocalServerReplication { $isDynamicRamEnabled = [System.Convert]::ToBoolean($IsDynamicMemoryEnabled) } $HasTargetVMRam = $PSBoundParameters.ContainsKey('TargetVMRam') + $HasTargetVirtualSwitchId = $PSBoundParameters.ContainsKey('TargetVirtualSwitchId') $HasTargetTestVirtualSwitchId = $PSBoundParameters.ContainsKey('TargetTestVirtualSwitchId') $parameterSet = $PSCmdlet.ParameterSetName - - $MachineIdArray = $MachineId.Split("/") - if ($MachineIdArray.Length -lt 11) { - throw "Invalid machine ARM ID '$MachineId'" + + # Validate ARM ID format from inputs + if (!(Test-AzureResourceIdFormat -Data $MachineId -Format $IdFormats.MachineArmIdTemplate)) { + throw "Invalid -MachineId '$MachineId'. A valid machine ARM ID should follow the format '$($IdFormats.MachineArmIdTemplate)'." + } + + if (!(Test-AzureResourceIdFormat -Data $TargetStoragePathId -Format $IdFormats.StoragePathArmIdTemplate)) { + throw "Invalid -TargetStoragePathId '$TargetStoragePathId'. A valid storage path ARM ID should follow the format '$($IdFormats.StoragePathArmIdTemplate)'." + } + + if (!(Test-AzureResourceIdFormat -Data $TargetResourceGroupId -Format $IdFormats.ResourceGroupArmIdTemplate)) { + throw "Invalid -TargetResourceGroupId '$TargetResourceGroupId'. A valid resource group ARM ID should follow the format '$($IdFormats.ResourceGroupArmIdTemplate)'." + } + + if ($HasTargetVirtualSwitchId -and !(Test-AzureResourceIdFormat -Data $TargetVirtualSwitchId -Format $IdFormats.LogicalNetworkArmIdTemplate)) { + throw "Invalid -TargetVirtualSwitchId '$TargetVirtualSwitchId'. A valid logical network ARM ID should follow the format '$($IdFormats.LogicalNetworkArmIdTemplate)'." } + + if ($HasTargetTestVirtualSwitchId -and !(Test-AzureResourceIdFormat -Data $TargetTestVirtualSwitchId -Format $IdFormats.LogicalNetworkArmIdTemplate)) { + throw "Invalid -TargetTestVirtualSwitchId '$TargetTestVirtualSwitchId'. A valid logical network ARM ID should follow the format '$($IdFormats.LogicalNetworkArmIdTemplate)'." + } + + # Extract information from $MachineId + $MachineIdArray = $MachineId.Split("/") $SiteType = $MachineIdArray[7] $SiteName = $MachineIdArray[8] $ResourceGroupName = $MachineIdArray[4] $MachineName = $MachineIdArray[10] # Get the source site and the discovered machine - if (($SiteType -ne $SiteTypes.HyperVSites) -and ($SiteType -ne $SiteTypes.VMwareSites)) { - throw "Site type is not supported. Site type '$SiteType'. Check MachineId provided." - } - if ($SiteType -eq $SiteTypes.HyperVSites) { $instanceType = $AzLocalInstanceTypes.HyperVToAzLocal @@ -318,11 +334,11 @@ function New-AzMigrateLocalServerReplication { } else { - throw "Unsupported site type '$SiteType'. Only Hyper-V and VMware sites are supported." + throw "Site type of '$SiteType' in -MachineId is not supported. Only '$($SiteTypes.HyperVSites)' and '$($SiteTypes.VMwareSites)' are supported." } if ([string]::IsNullOrEmpty($runAsAccountId)) { - throw "Unable to determine RunAsAccount for site '$SiteName' from machine '$MachineName'. Please verify your appliance setup." + throw "Unable to determine RunAsAccount for site '$SiteName' from machine '$MachineName'. Please verify your appliance setup and provided -MachineId." } # Validate the VM @@ -560,7 +576,6 @@ function New-AzMigrateLocalServerReplication { $customProperties.TargetHciClusterId = $targetClusterId $customProperties.TargetResourceGroupId = $TargetResourceGroupId $customProperties.TargetVMName = $TargetVMName - $customProperties.TargetCpuCore = if ($HasTargetVMCPUCore) { $TargetVMCPUCore } else { $machine.NumberOfProcessorCore } $customProperties.IsDynamicRam = if ($HasIsDynamicMemoryEnabled) { $isDynamicRamEnabled } else { $isSourceDynamicMemoryEnabled } # Determine target VM Hyper-V Generation @@ -573,11 +588,37 @@ function New-AzMigrateLocalServerReplication { $customProperties.HyperVGeneration = if ($machine.Firmware -ieq "BIOS") { "1" } else { "2" } } + # Validate TargetVMCPUCore + if ($HasTargetVMCPUCore) + { + if ($TargetVMCPUCore -lt 1 -or $TargetVMCPUCore -gt 64) + { + throw "Specify -TargetVMCPUCore between 1 and 64." + } + $customProperties.TargetCpuCore = $TargetVMCPUCore + } + else + { + $customProperties.TargetCpuCore = $machine.NumberOfProcessorCore + } + # Validate TargetVMRam - if ($HasTargetVMRam) { - # TargetVMRam needs to be greater than 0 - if ($TargetVMRam -le 0) { - throw "Specify a target RAM that is greater than 0" + if ($HasTargetVMRam) + { + if ($customProperties.HyperVGeneration -eq "1") { + # Between 512 MB and 1 TB + if ($TargetVMRam -lt 512 -or $TargetVMRam -gt 1048576) + { + throw "Specify -TargetVMRAM between 512 and 1048576 MB (i.e., 1 TB) for Hyper-V Generation 1 VM." + } + } + else # Hyper-V Generation 2 + { + # Between 32 MB and 12 TB + if ($TargetVMRam -lt 32 -or $TargetVMRam -gt 12582912) + { + throw "Specify -TargetVMRAM between 32 and 12582912 MB (i.e., 12 TB) for Hyper-V Generation 2 VM." + } } $customProperties.TargetMemoryInMegaByte = $TargetVMRam @@ -604,22 +645,12 @@ function New-AzMigrateLocalServerReplication { if ($null -eq $osDisk) { throw "No Disk found with InstanceId $OSDiskID from discovered machine disks." } - - $diskName = Split-Path $osDisk.Path -leaf - if (IsReservedOrTrademarked($diskName)) { - throw "The disk name $diskName or part of the name is a trademarked or reserved word." - } } elseif ($SiteType -eq $SiteTypes.VMwareSites) { $osDisk = $machine.Disk | Where-Object { $_.Uuid -eq $OSDiskID } if ($null -eq $osDisk) { throw "No Disk found with Uuid $OSDiskID from discovered machine disks." } - - $diskName = Split-Path $osDisk.Path -leaf - if (IsReservedOrTrademarked($diskName)) { - throw "The disk name $diskName or part of the name is a trademarked or reserved word." - } } foreach ($sourceDisk in $machine.Disk) { @@ -663,14 +694,14 @@ function New-AzMigrateLocalServerReplication { # Validate DiskToInclude [PSCustomObject[]]$uniqueDisks = @() foreach ($disk in $DiskToInclude) { - # VHD is not supported as OS disk in Gen2 VMs - if ($customProperties.HyperVGeneration -eq "2" -and $disk.DiskFileFormat -eq "VHD" -and $disk.IsOSDisk) { - throw "VHD disks cannot be used as the OS disk of Hyper-V Generation 2 VMs. Please replace disk with id '$($disk.DiskId)' in -DiskToInclude by re-running New-AzMigrateLocalDiskMappingObject with 'VHDX' as Format." + # Enforce VHDX for Gen2 VMs + if ($customProperties.HyperVGeneration -eq "2" -and $disk.DiskFileFormat -eq "VHD") { + throw "Please specify 'VHDX' as Format for the disk with id '$($disk.DiskId)' in -DiskToInclude by re-running New-AzMigrateLocalDiskMappingObject." } - # PhysicalSectorSize must be 512 for VHD format - if ($disk.DiskFileFormat -eq "VHD" -and $disk.DiskPhysicalSectorSize -ne 512) { - throw "PhysicalSectorSize must be 512 for VHD format. Please replace disk with id '$($disk.DiskId)' in -DiskToInclude by re-running New-AzMigrateLocalDiskMappingObject with 512 as PhysicalSectorSize." + # PhysicalSectorSize must be 512 for VHD format if it is set + if ($disk.DiskFileFormat -eq "VHD" -and $null -ne $disk.DiskPhysicalSectorSize -and $disk.DiskPhysicalSectorSize -ne 512) { + throw "Invalid Physical sector size of $($disk.DiskPhysicalSectorSize) is found for VHD format. Please replace disk with id '$($disk.DiskId)' in -DiskToInclude by re-running New-AzMigrateLocalDiskMappingObject with 512 as -PhysicalSectorSize." } if ($SiteType -eq $SiteTypes.HyperVSites) { @@ -686,11 +717,6 @@ function New-AzMigrateLocalServerReplication { } } - $diskName = Split-Path -Path $discoveredDisk.Path -Leaf - if (IsReservedOrTrademarked($diskName)) { - throw "The disk name $diskName or part of the name is a trademarked or reserved word." - } - if ($uniqueDisks.Contains($disk.DiskId)) { throw "The disk id '$($disk.DiskId)' is already taken." } diff --git a/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 index 48d00416bf9f..5e137128624f 100644 --- a/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 @@ -152,6 +152,11 @@ function Set-AzMigrateLocalServerReplication { $null = $PSBoundParameters.Remove('OsType') $null = $PSBoundParameters.Remove('WhatIf') $null = $PSBoundParameters.Remove('Confirm') + + # Validate ARM ID format from inputs + if (!(Test-AzureResourceIdFormat -Data $TargetObjectID -Format $IdFormats.ProtectedItemArmIdTemplate)) { + throw "Invalid -TargetObjectID '$TargetObjectID'. A valid protected item ARM ID should follow the format '$($IdFormats.ProtectedItemArmIdTemplate)'." + } $ProtectedItemIdArray = $TargetObjectID.Split("/") $ResourceGroupName = $ProtectedItemIdArray[4] @@ -196,17 +201,29 @@ function Set-AzMigrateLocalServerReplication { # Update target CPU core if ($HasTargetVMCPUCore) { - if ($TargetVMCPUCore -le 0) { - throw "Specify target CPU core greater than 0" + if ($TargetVMCPUCore -lt 1 -or $TargetVMCPUCore -gt 64) + { + throw "Specify -TargetVMCPUCore between 1 and 64." } - $customPropertiesUpdate.TargetCpuCore = $TargetVMCPUCore } - # Update VM Ram + # Update TargetVMRam if ($HasTargetVMRam) { - if ($TargetVMRam -le 0) { - throw "Specify target RAM greater than 0" + if ($customProperties.HyperVGeneration -eq "1") { + # Between 512 MB and 1 TB + if ($TargetVMRam -lt 512 -or $TargetVMRam -gt 1048576) + { + throw "Specify -TargetVMRAM between 512 and 1048576 MB (i.e., 1 TB) for Hyper-V Generation 1 VM." + } + } + else # Hyper-V Generation 2 + { + # Between 32 MB and 12 TB + if ($TargetVMRam -lt 32 -or $TargetVMRam -gt 12582912) + { + throw "Specify -TargetVMRAM between 32 and 12582912 MB (i.e., 12 TB) for Hyper-V Generation 2 VM." + } } $customPropertiesUpdate.TargetMemoryInMegaByte = $TargetVMRam diff --git a/src/Migrate/Migrate.Autorest/docs/New-AzMigrateLocalServerReplication.md b/src/Migrate/Migrate.Autorest/docs/New-AzMigrateLocalServerReplication.md index 137d19b2b8ac..80d24ffa4955 100644 --- a/src/Migrate/Migrate.Autorest/docs/New-AzMigrateLocalServerReplication.md +++ b/src/Migrate/Migrate.Autorest/docs/New-AzMigrateLocalServerReplication.md @@ -195,7 +195,7 @@ Accept wildcard characters: False ``` ### -OSDiskID -Specifies the Operating System disk for the source server to be migrated. +Specifies the operating system disk for the source server to be migrated. ```yaml Type: System.String @@ -255,7 +255,7 @@ Accept wildcard characters: False ``` ### -TargetResourceGroupId -Specifies the target Resource Group Id where the migrated VM resources will reside. +Specifies the target resource group ARM ID where the migrated VM resources will reside. ```yaml Type: System.String diff --git a/src/Migrate/Migrate/ChangeLog.md b/src/Migrate/Migrate/ChangeLog.md index c02b755e8255..acd790e88945 100644 --- a/src/Migrate/Migrate/ChangeLog.md +++ b/src/Migrate/Migrate/ChangeLog.md @@ -18,8 +18,16 @@ - Additional information about change #1 --> ## Upcoming Release -* Fixed bugs in `New-AzMigrateLocalDiskMappingObject` to validate for non-512 physical sector size of VHD. -* Fixed bugs in `New-AzMigrateLocalServerReplication` to validate for VHD as OS disk of Hyper-V Generation 2 VMs. +* Fixed bugs in `New-AzMigrateLocalDiskMappingObject` + - Only validate for non-512 physical sector size of VHD when `-PhysicalSectorSize` parameter is given +* Fixed bugs in `New-AzMigrateLocalServerReplication` + - Only validate for non-512 physical sector size of VHD when `-PhysicalSectorSize` parameter is given + - Removed reserved words validation for source disk names as it is no longer required + - Added ARM id validation for input parameters +* Fixed bugs in `Set-AzMigrateLocalServerReplication` + - Added ARM id validation for input parameters +* Fixed bugs in `Get-AzMigrateLocalServerReplication` + - Added ARM id validation for input parameters ## Version 2.9.0 * Added `-OsType` as an optional parameter to command `Set-AzMigrateLocalServerReplication` to allow user-specified OS type. From dc00a028e8e6fc55f45c96393a0691e96cffb83b Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Wed, 17 Sep 2025 10:55:50 -0700 Subject: [PATCH 5/7] Address PR comments --- .../Properties/AssemblyInfo.cs | 4 +-- .../Get-AzMigrateLocalServerReplication.ps1 | 27 ++++++++++++------- .../custom/Helper/AzLocalCommonSettings.ps1 | 12 +++++++++ .../New-AzMigrateLocalServerReplication.ps1 | 23 ++++++++-------- .../Set-AzMigrateLocalServerReplication.ps1 | 22 ++++++++------- 5 files changed, 56 insertions(+), 32 deletions(-) diff --git a/src/Migrate/Migrate.Autorest/Properties/AssemblyInfo.cs b/src/Migrate/Migrate.Autorest/Properties/AssemblyInfo.cs index cdc548a94515..9b94307f162a 100644 --- a/src/Migrate/Migrate.Autorest/Properties/AssemblyInfo.cs +++ b/src/Migrate/Migrate.Autorest/Properties/AssemblyInfo.cs @@ -20,7 +20,7 @@ [assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")] [assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")] [assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - Migrate")] -[assembly: System.Reflection.AssemblyFileVersionAttribute("2.8.0")] -[assembly: System.Reflection.AssemblyVersionAttribute("2.8.0")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("2.9.0")] +[assembly: System.Reflection.AssemblyVersionAttribute("2.9.0")] [assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)] [assembly: System.CLSCompliantAttribute(false)] diff --git a/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 index d6e737b4a8b5..c3697094ac3d 100644 --- a/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 @@ -168,11 +168,13 @@ function Get-AzMigrateLocalServerReplication { } if ($parameterSet -eq 'GetBySDSID') { + # $DiscoveredMachineId is in the format of + # "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.OffAzure/{2}/{3}/machines/{4}" $machineIdArray = $DiscoveredMachineId.Split("/") - $siteType = $machineIdArray[7] - $siteName = $machineIdArray[8] - $ResourceGroupName = $machineIdArray[4] - $ProtectedItemName = $machineIdArray[10] + $ResourceGroupName = $machineIdArray[4] # {1} + $siteType = $machineIdArray[7] # {2} + $siteName = $machineIdArray[8] # {3} + $ProtectedItemName = $machineIdArray[10] # {4} $null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) $null = $PSBoundParameters.Add('SiteName', $siteName) @@ -227,10 +229,14 @@ function Get-AzMigrateLocalServerReplication { if (($parameterSet -match 'List') -or ($parameterSet -eq 'GetByMachineName')) { # Retrieve ResourceGroupName, ProjectName if ListByID if ($parameterSet -eq 'ListByID') { + # $ResourceGroupID is in the format of "/subscriptions/{0}/resourceGroups/{1}" $resourceGroupIdArray = $ResourceGroupID.Split('/') - $ResourceGroupName = $resourceGroupIdArray[4] + $ResourceGroupName = $resourceGroupIdArray[4] # {1} + + # ProjecyID is in the format of + # "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Migrate/MigrateProjects/{2}" $projectIdArray = $ProjectID.Split('/') - $ProjectName = $projectIdArray[8] + $ProjectName = $projectIdArray[8] # {2} } $amhSolutionName = "Servers-Migration-ServerMigration_DataReplication" @@ -265,10 +271,13 @@ function Get-AzMigrateLocalServerReplication { if ($parameterSet -eq 'GetByInputObject') { $TargetObjectID = $InputObject.Id } + + # $TargetObjectID is in the format of + # "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.DataReplication/replicationVaults/{2}/protectedItems/{3}" $objectIdArray = $TargetObjectID.Split("/") - $ResourceGroupName = $objectIdArray[4] - $VaultName = $objectIdArray[8] - $ProtectedItemName = $objectIdArray[10] + $ResourceGroupName = $objectIdArray[4] # {1} + $VaultName = $objectIdArray[8] # {2} + $ProtectedItemName = $objectIdArray[10] # {3} $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) $null = $PSBoundParameters.Add("VaultName", $VaultName) $null = $PSBoundParameters.Add("Name", $ProtectedItemName) diff --git a/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonSettings.ps1 b/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonSettings.ps1 index cc1a6df7eba8..4723df883890 100644 --- a/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonSettings.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonSettings.ps1 @@ -130,4 +130,16 @@ $IdFormats = @{ LogicalNetworkArmIdTemplate = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.AzureStackHCI/logicalnetworks/{2}" MigrateProjectArmIdTemplate = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Migrate/MigrateProjects/{2}" ProtectedItemArmIdTemplate = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.DataReplication/replicationVaults/{2}/protectedItems/{3}" +} + +$TargetVMCPUCores = @{ + Min = 1 + Max = 64 +} + +$TargetVMRamInMB = @{ + Gen1Min = 512 + Gen1Max = 1048576 # 1 TB + Gen2Min = 32 + Gen2Max = 12582912 # 12 TB } \ No newline at end of file diff --git a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 index 4a88584c1045..c048c3279993 100644 --- a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 @@ -206,12 +206,13 @@ function New-AzMigrateLocalServerReplication { throw "Invalid -TargetTestVirtualSwitchId '$TargetTestVirtualSwitchId'. A valid logical network ARM ID should follow the format '$($IdFormats.LogicalNetworkArmIdTemplate)'." } - # Extract information from $MachineId + # $MachineId is in the format of + # "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.OffAzure/{2}/{3}/machines/{4}" $MachineIdArray = $MachineId.Split("/") - $SiteType = $MachineIdArray[7] - $SiteName = $MachineIdArray[8] - $ResourceGroupName = $MachineIdArray[4] - $MachineName = $MachineIdArray[10] + $ResourceGroupName = $MachineIdArray[4] # {1} + $SiteType = $MachineIdArray[7] # {2} + $SiteName = $MachineIdArray[8] # {3} + $MachineName = $MachineIdArray[10] # {4} # Get the source site and the discovered machine if ($SiteType -eq $SiteTypes.HyperVSites) { @@ -591,9 +592,9 @@ function New-AzMigrateLocalServerReplication { # Validate TargetVMCPUCore if ($HasTargetVMCPUCore) { - if ($TargetVMCPUCore -lt 1 -or $TargetVMCPUCore -gt 64) + if ($TargetVMCPUCore -lt $TargetVMCPUCores.Min -or $TargetVMCPUCore -gt $TargetVMCPUCores.Max) { - throw "Specify -TargetVMCPUCore between 1 and 64." + throw "Specify -TargetVMCPUCore between $($TargetVMCPUCores.Min) and $($TargetVMCPUCores.Max)." } $customProperties.TargetCpuCore = $TargetVMCPUCore } @@ -607,17 +608,17 @@ function New-AzMigrateLocalServerReplication { { if ($customProperties.HyperVGeneration -eq "1") { # Between 512 MB and 1 TB - if ($TargetVMRam -lt 512 -or $TargetVMRam -gt 1048576) + if ($TargetVMRam -lt $TargetVMRamInMB.Gen1Min -or $TargetVMRam -gt $TargetVMRamInMB.Gen1Max) { - throw "Specify -TargetVMRAM between 512 and 1048576 MB (i.e., 1 TB) for Hyper-V Generation 1 VM." + throw "Specify -TargetVMRAM between $($TargetVMRamInMB.Gen1Min) and $($TargetVMRamInMB.Gen1Max) MB (i.e., 1 TB) for Hyper-V Generation 1 VM." } } else # Hyper-V Generation 2 { # Between 32 MB and 12 TB - if ($TargetVMRam -lt 32 -or $TargetVMRam -gt 12582912) + if ($TargetVMRam -lt $TargetVMRamInMB.Gen2Min -or $TargetVMRam -gt $TargetVMRamInMB.Gen2Max) { - throw "Specify -TargetVMRAM between 32 and 12582912 MB (i.e., 12 TB) for Hyper-V Generation 2 VM." + throw "Specify -TargetVMRAM between $($TargetVMRamInMB.Gen2Min) and $($TargetVMRamInMB.Gen2Max) MB (i.e., 12 TB) for Hyper-V Generation 2 VM." } } diff --git a/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 index 5e137128624f..192583c0e847 100644 --- a/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 @@ -158,11 +158,13 @@ function Set-AzMigrateLocalServerReplication { throw "Invalid -TargetObjectID '$TargetObjectID'. A valid protected item ARM ID should follow the format '$($IdFormats.ProtectedItemArmIdTemplate)'." } + # $TargetObjectID is in the format of + # "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.DataReplication/replicationVaults/{2}/protectedItems/{3}" $ProtectedItemIdArray = $TargetObjectID.Split("/") - $ResourceGroupName = $ProtectedItemIdArray[4] - $VaultName = $ProtectedItemIdArray[8] - $MachineName = $ProtectedItemIdArray[10] - + $ResourceGroupName = $ProtectedItemIdArray[4] # {1} + $VaultName = $ProtectedItemIdArray[8] # {2} + $MachineName = $ProtectedItemIdArray[10] # {3} + # Get existing Protected Item $null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName) $null = $PSBoundParameters.Add("VaultName", $VaultName) @@ -201,9 +203,9 @@ function Set-AzMigrateLocalServerReplication { # Update target CPU core if ($HasTargetVMCPUCore) { - if ($TargetVMCPUCore -lt 1 -or $TargetVMCPUCore -gt 64) + if ($TargetVMCPUCore -lt $TargetVMCPUCores.Min -or $TargetVMCPUCore -gt $TargetVMCPUCores.Max) { - throw "Specify -TargetVMCPUCore between 1 and 64." + throw "Specify -TargetVMCPUCore between $($TargetVMCPUCores.Min) and $($TargetVMCPUCores.Max)." } $customPropertiesUpdate.TargetCpuCore = $TargetVMCPUCore } @@ -212,17 +214,17 @@ function Set-AzMigrateLocalServerReplication { if ($HasTargetVMRam) { if ($customProperties.HyperVGeneration -eq "1") { # Between 512 MB and 1 TB - if ($TargetVMRam -lt 512 -or $TargetVMRam -gt 1048576) + if ($TargetVMRam -lt $TargetVMRamInMB.Gen1Min -or $TargetVMRam -gt $TargetVMRamInMB.Gen1Max) { - throw "Specify -TargetVMRAM between 512 and 1048576 MB (i.e., 1 TB) for Hyper-V Generation 1 VM." + throw "Specify -TargetVMRAM between $($TargetVMRamInMB.Gen1Min) and $($TargetVMRamInMB.Gen1Max) MB (i.e., 1 TB) for Hyper-V Generation 1 VM." } } else # Hyper-V Generation 2 { # Between 32 MB and 12 TB - if ($TargetVMRam -lt 32 -or $TargetVMRam -gt 12582912) + if ($TargetVMRam -lt $TargetVMRamInMB.Gen2Min -or $TargetVMRam -gt $TargetVMRamInMB.Gen2Max) { - throw "Specify -TargetVMRAM between 32 and 12582912 MB (i.e., 12 TB) for Hyper-V Generation 2 VM." + throw "Specify -TargetVMRAM between $($TargetVMRamInMB.Gen2Min) and $($TargetVMRamInMB.Gen2Max) MB (i.e., 12 TB) for Hyper-V Generation 2 VM." } } From ca271d4cb23d9e0eddea3727c3a2112f1b6a6b10 Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Fri, 19 Sep 2025 10:16:36 -0700 Subject: [PATCH 6/7] Update import module path to unblock linux build --- .../custom/Get-AzMigrateLocalServerReplication.ps1 | 6 ++++-- .../Initialize-AzMigrateLocalReplicationInfrastructure.ps1 | 6 ++++-- .../Initialize-AzMigrateReplicationInfrastructure.ps1 | 3 ++- .../custom/New-AzMigrateLocalServerReplication.ps1 | 6 ++++-- .../custom/Set-AzMigrateLocalServerReplication.ps1 | 6 ++++-- .../custom/Start-AzMigrateLocalServerMigration.ps1 | 6 ++++-- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 index c3697094ac3d..d84ced8f2116 100644 --- a/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 @@ -132,8 +132,10 @@ function Get-AzMigrateLocalServerReplication { ) process { - Import-Module $PSScriptRoot\Helper\AzLocalCommonSettings.ps1 - Import-Module $PSScriptRoot\Helper\AZLocalCommonHelper.ps1 + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + Import-Module $helperPath + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AZLocalCommonHelper.ps1' + Import-Module $helperPath $hasTargetObjectId = $PSBoundParameters.ContainsKey('TargetObjectID') $hasDiscoveredMachineId = $PSBoundParameters.ContainsKey('DiscoveredMachineId') diff --git a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 index bfd456fbc5d1..2c0fdd9fc869 100644 --- a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 @@ -120,8 +120,10 @@ function Initialize-AzMigrateLocalReplicationInfrastructure { ) process { - Import-Module $PSScriptRoot\Helper\AzLocalCommonSettings.ps1 - Import-Module $PSScriptRoot\Helper\AZLocalCommonHelper.ps1 + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + Import-Module $helperPath + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AZLocalCommonHelper.ps1' + Import-Module $helperPath CheckResourcesModuleDependency CheckStorageModuleDependency diff --git a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateReplicationInfrastructure.ps1 b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateReplicationInfrastructure.ps1 index 78573a1011aa..ac960d7120c0 100644 --- a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateReplicationInfrastructure.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateReplicationInfrastructure.ps1 @@ -134,7 +134,8 @@ function Initialize-AzMigrateReplicationInfrastructure { Import-Module Az.Resources Import-Module Az.Storage Import-Module Az.RecoveryServices - Import-Module $PSScriptRoot\Helper\AzLocalCommonSettings.ps1 + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + Import-Module $helperPath # Validate user specified target region $TargetRegion = $TargetRegion.ToLower() diff --git a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 index c048c3279993..4494d02e9377 100644 --- a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 @@ -169,8 +169,10 @@ function New-AzMigrateLocalServerReplication { ) process { - Import-Module $PSScriptRoot\Helper\AzLocalCommonSettings.ps1 - Import-Module $PSScriptRoot\Helper\AZLocalCommonHelper.ps1 + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + Import-Module $helperPath + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AZLocalCommonHelper.ps1' + Import-Module $helperPath CheckResourceGraphModuleDependency CheckResourcesModuleDependency diff --git a/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 index 192583c0e847..0efe50b07748 100644 --- a/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 @@ -128,8 +128,10 @@ function Set-AzMigrateLocalServerReplication { ) process { - Import-Module $PSScriptRoot\Helper\AzLocalCommonSettings.ps1 - Import-Module $PSScriptRoot\Helper\AZLocalCommonHelper.ps1 + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + Import-Module $helperPath + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AZLocalCommonHelper.ps1' + Import-Module $helperPath CheckResourcesModuleDependency diff --git a/src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1 b/src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1 index 100204b5dc31..f2280c183350 100644 --- a/src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1 @@ -100,8 +100,10 @@ function Start-AzMigrateLocalServerMigration { ) process { - Import-Module $PSScriptRoot\Helper\AzLocalCommonSettings.ps1 - Import-Module $PSScriptRoot\Helper\AZLocalCommonHelper.ps1 + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + Import-Module $helperPath + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AZLocalCommonHelper.ps1' + Import-Module $helperPath CheckResourceGraphModuleDependency CheckResourcesModuleDependency From 23b9e46e1dc584b28b37ca0e442e60b10028ac5d Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Fri, 19 Sep 2025 15:11:22 -0700 Subject: [PATCH 7/7] Correct typo --- .../custom/Get-AzMigrateLocalServerReplication.ps1 | 2 +- .../Initialize-AzMigrateLocalReplicationInfrastructure.ps1 | 2 +- .../custom/New-AzMigrateLocalServerReplication.ps1 | 2 +- .../custom/Set-AzMigrateLocalServerReplication.ps1 | 2 +- .../custom/Start-AzMigrateLocalServerMigration.ps1 | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 index d84ced8f2116..723171f9d231 100644 --- a/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 @@ -134,7 +134,7 @@ function Get-AzMigrateLocalServerReplication { process { $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' Import-Module $helperPath - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AZLocalCommonHelper.ps1' + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonHelper.ps1' Import-Module $helperPath $hasTargetObjectId = $PSBoundParameters.ContainsKey('TargetObjectID') diff --git a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 index 2c0fdd9fc869..f15b60284457 100644 --- a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 @@ -122,7 +122,7 @@ function Initialize-AzMigrateLocalReplicationInfrastructure { process { $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' Import-Module $helperPath - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AZLocalCommonHelper.ps1' + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonHelper.ps1' Import-Module $helperPath CheckResourcesModuleDependency diff --git a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 index 4494d02e9377..d641c7ddf999 100644 --- a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 @@ -171,7 +171,7 @@ function New-AzMigrateLocalServerReplication { process { $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' Import-Module $helperPath - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AZLocalCommonHelper.ps1' + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonHelper.ps1' Import-Module $helperPath CheckResourceGraphModuleDependency diff --git a/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 index 0efe50b07748..f7bbd885103d 100644 --- a/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 @@ -130,7 +130,7 @@ function Set-AzMigrateLocalServerReplication { process { $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' Import-Module $helperPath - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AZLocalCommonHelper.ps1' + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonHelper.ps1' Import-Module $helperPath CheckResourcesModuleDependency diff --git a/src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1 b/src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1 index f2280c183350..73ece63eadc8 100644 --- a/src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1 @@ -102,7 +102,7 @@ function Start-AzMigrateLocalServerMigration { process { $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' Import-Module $helperPath - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AZLocalCommonHelper.ps1' + $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonHelper.ps1' Import-Module $helperPath CheckResourceGraphModuleDependency