From 83437fab69b920e897c07b2184589c4bd3823e23 Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Thu, 9 Oct 2025 16:24:22 -0700 Subject: [PATCH 1/3] Fix AMH solution tool ServerMigration_DataReplication --- ...zMigrateLocalReplicationInfrastructure.ps1 | 41 +++++++++++++++---- src/Migrate/Migrate/ChangeLog.md | 2 + 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 index f15b60284457..8b8e524517d0 100644 --- a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 @@ -586,32 +586,51 @@ function Initialize-AzMigrateLocalReplicationInfrastructure { # amhStoredStorageAccount exists and in Succeeded state if ($null -ne $amhStoredStorageAccount -and - $amhStoredStorageAccount.ProvisioningState -eq [StorageAccountProvisioningState]::Succeeded) { + $amhStoredStorageAccount.ProvisioningState -eq [StorageAccountProvisioningState]::Succeeded) + { # Use amhStoredStorageAccount and ignore user provided Cache Storage Account Id - if (![string]::IsNullOrEmpty($CacheStorageAccountId) -and $amhStoredStorageAccount.Id -ne $CacheStorageAccountId) { + if (![string]::IsNullOrEmpty($CacheStorageAccountId) -and $amhStoredStorageAccount.Id -ne $CacheStorageAccountId) + { Write-Host "A Cache Storage Account '$($amhStoredStorageAccountName)' has been linked already. The given -CacheStorageAccountId '$($CacheStorageAccountId)' will be ignored." } $cacheStorageAccount = $amhStoredStorageAccount + + # This will fix brownfield issue where AMH solution tool is set incorrectly that causes UX bifracation to go to the wrong experience; + # for new projects that are set correctly from the start, this will essentailly be a no-op. + Az.Migrate.Internal\Set-AzMigrateSolution ` + -MigrateProjectName $ProjectName ` + -Name $amhSolution.Name ` + -ResourceGroupName $ResourceGroupName ` + -DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties ` + -Tool "ServerMigration_DataReplication" ` + -Purpose "Migration" | Out-Null } - elseif ($null -eq $amhStoredStorageAccount -or $null -eq $amhStoredStorageAccount.ProvisioningState) { + elseif ($null -eq $amhStoredStorageAccount -or $null -eq $amhStoredStorageAccount.ProvisioningState) + { # amhStoredStorageAccount is found but in a bad state, so log to ask user to remove - if ($null -ne $amhStoredStorageAccount -and $null -eq $amhStoredStorageAccount.ProvisioningState) { + if ($null -ne $amhStoredStorageAccount -and $null -eq $amhStoredStorageAccount.ProvisioningState) + { Write-Host "A previously linked Cache Storage Account with Id '$($amhStoredStorageAccountId)' is found but in a unusable state. Please remove it manually and re-run this command." } # amhStoredStorageAccount is not found or in a bad state but AMH has a record of it, so remove the record - if ($amhSolution.DetailExtendedDetail.ContainsKey("replicationStorageAccountId")) { + if ($amhSolution.DetailExtendedDetail.ContainsKey("replicationStorageAccountId")) + { $amhSolution.DetailExtendedDetail.Remove("replicationStorageAccountId") | Out-Null $amhSolution.DetailExtendedDetail.Add("replicationStorageAccountId", $null) | Out-Null + Az.Migrate.Internal\Set-AzMigrateSolution ` -MigrateProjectName $ProjectName ` -Name $amhSolution.Name ` -ResourceGroupName $ResourceGroupName ` - -DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties | Out-Null + -DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties ` + -Tool "ServerMigration_DataReplication" ` + -Purpose "Migration"| Out-Null } } - else { + else + { throw "A linked Cache Storage Account with Id '$($amhStoredStorageAccountId)' times out with Provisioning State: '$($amhStoredStorageAccount.ProvisioningState)'. Please re-run this command or contact support if help needed." } @@ -928,13 +947,17 @@ function Initialize-AzMigrateLocalReplicationInfrastructure { } # Update AMH record with chosen Cache Storage Account - if (!$amhSolution.DetailExtendedDetail.ContainsKey("replicationStorageAccountId")) { + if (!$amhSolution.DetailExtendedDetail.ContainsKey("replicationStorageAccountId")) + { $amhSolution.DetailExtendedDetail.Add("replicationStorageAccountId", $cacheStorageAccount.Id) + Az.Migrate.Internal\Set-AzMigrateSolution ` -MigrateProjectName $ProjectName ` -Name $amhSolution.Name ` -ResourceGroupName $ResourceGroupName ` - -DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties | Out-Null + -DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties ` + -Tool "ServerMigration_DataReplication" ` + -Purpose "Migration"| Out-Null } Write-Host "*Selected Cache Storage Account: '$($cacheStorageAccount.StorageAccountName)' in Resource Group '$($ResourceGroupName)' at Location '$($cacheStorageAccount.Location)' for Migrate Project '$($migrateProject.Name)'" diff --git a/src/Migrate/Migrate/ChangeLog.md b/src/Migrate/Migrate/ChangeLog.md index 623ee282085b..c49a63bb214e 100644 --- a/src/Migrate/Migrate/ChangeLog.md +++ b/src/Migrate/Migrate/ChangeLog.md @@ -29,6 +29,8 @@ * Fixed bugs in `Get-AzMigrateLocalServerReplication` - Added ARM id validation for input parameters * Enhanced Get-AzMigrateServerMigrationStatus to add support for the -Expedite parameter. +* Fixed bugs in `Initialize-AzMigrateLocalReplicationInfrastructure` + - Correct AMH solution tool name of "ServerMigration_DataReplication" is now being passed in to address replication count missing and UX bifracation experience issues in Azure Migrate on Azure portal. ## Version 2.9.0 * Added `-OsType` as an optional parameter to command `Set-AzMigrateLocalServerReplication` to allow user-specified OS type. From 7d0011e588db74923d6d4877ec31d5c293f58ce9 Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Thu, 9 Oct 2025 16:27:44 -0700 Subject: [PATCH 2/3] Fix typo --- ...Initialize-AzMigrateLocalReplicationInfrastructure.ps1 | 8 ++++---- src/Migrate/Migrate/ChangeLog.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 index 8b8e524517d0..729bde5377aa 100644 --- a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 @@ -596,8 +596,8 @@ function Initialize-AzMigrateLocalReplicationInfrastructure { $cacheStorageAccount = $amhStoredStorageAccount - # This will fix brownfield issue where AMH solution tool is set incorrectly that causes UX bifracation to go to the wrong experience; - # for new projects that are set correctly from the start, this will essentailly be a no-op. + # This will fix brownfield issue where AMH solution tool is set incorrectly that causes UX bifurcation to go to the wrong experience; + # for new projects that are set correctly from the start, this will essentially be a no-op. Az.Migrate.Internal\Set-AzMigrateSolution ` -MigrateProjectName $ProjectName ` -Name $amhSolution.Name ` @@ -626,7 +626,7 @@ function Initialize-AzMigrateLocalReplicationInfrastructure { -ResourceGroupName $ResourceGroupName ` -DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties ` -Tool "ServerMigration_DataReplication" ` - -Purpose "Migration"| Out-Null + -Purpose "Migration" | Out-Null } } else @@ -957,7 +957,7 @@ function Initialize-AzMigrateLocalReplicationInfrastructure { -ResourceGroupName $ResourceGroupName ` -DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties ` -Tool "ServerMigration_DataReplication" ` - -Purpose "Migration"| Out-Null + -Purpose "Migration" | Out-Null } Write-Host "*Selected Cache Storage Account: '$($cacheStorageAccount.StorageAccountName)' in Resource Group '$($ResourceGroupName)' at Location '$($cacheStorageAccount.Location)' for Migrate Project '$($migrateProject.Name)'" diff --git a/src/Migrate/Migrate/ChangeLog.md b/src/Migrate/Migrate/ChangeLog.md index c49a63bb214e..f7b1823bd8b7 100644 --- a/src/Migrate/Migrate/ChangeLog.md +++ b/src/Migrate/Migrate/ChangeLog.md @@ -30,7 +30,7 @@ - Added ARM id validation for input parameters * Enhanced Get-AzMigrateServerMigrationStatus to add support for the -Expedite parameter. * Fixed bugs in `Initialize-AzMigrateLocalReplicationInfrastructure` - - Correct AMH solution tool name of "ServerMigration_DataReplication" is now being passed in to address replication count missing and UX bifracation experience issues in Azure Migrate on Azure portal. + - Correct AMH solution tool name of "ServerMigration_DataReplication" is now being passed in to address replication count missing and UX experience load issues in Azure Migrate on Azure portal. ## Version 2.9.0 * Added `-OsType` as an optional parameter to command `Set-AzMigrateLocalServerReplication` to allow user-specified OS type. From f96302eeb3e67fb28462b5039642b1392cec7421 Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Fri, 10 Oct 2025 00:02:59 -0700 Subject: [PATCH 3/3] Address Join-Path with older PS version --- .../custom/Get-AzMigrateLocalServerReplication.ps1 | 4 ++-- .../Initialize-AzMigrateLocalReplicationInfrastructure.ps1 | 4 ++-- .../custom/Initialize-AzMigrateReplicationInfrastructure.ps1 | 2 +- .../custom/New-AzMigrateLocalServerReplication.ps1 | 4 ++-- .../custom/Set-AzMigrateLocalServerReplication.ps1 | 4 ++-- .../custom/Start-AzMigrateLocalServerMigration.ps1 | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 index 723171f9d231..ccf3b66ebb2d 100644 --- a/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1 @@ -132,9 +132,9 @@ function Get-AzMigrateLocalServerReplication { ) process { - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + $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 729bde5377aa..1513a79fc4f5 100644 --- a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 @@ -120,9 +120,9 @@ function Initialize-AzMigrateLocalReplicationInfrastructure { ) process { - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + $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/Initialize-AzMigrateReplicationInfrastructure.ps1 b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateReplicationInfrastructure.ps1 index ac960d7120c0..8ac93e32f36c 100644 --- a/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateReplicationInfrastructure.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateReplicationInfrastructure.ps1 @@ -134,7 +134,7 @@ function Initialize-AzMigrateReplicationInfrastructure { Import-Module Az.Resources Import-Module Az.Storage Import-Module Az.RecoveryServices - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + $helperPath = Join-Path $PSScriptRoot 'Helper\AzLocalCommonSettings.ps1' Import-Module $helperPath # Validate user specified target region diff --git a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 index d641c7ddf999..d7066cd32b08 100644 --- a/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 @@ -169,9 +169,9 @@ function New-AzMigrateLocalServerReplication { ) process { - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + $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 f7bbd885103d..419c52de8ac3 100644 --- a/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1 @@ -128,9 +128,9 @@ function Set-AzMigrateLocalServerReplication { ) process { - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + $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 73ece63eadc8..4866cb74ee4d 100644 --- a/src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1 +++ b/src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1 @@ -100,9 +100,9 @@ function Start-AzMigrateLocalServerMigration { ) process { - $helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1' + $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