Skip to content

Commit fa532bd

Browse files
minhsuanleeSam Lee
andauthored
Fix AMH solution tool ServerMigration_DataReplication (#28665)
Co-authored-by: Sam Lee <[email protected]>
1 parent e2b2b12 commit fa532bd

7 files changed

+52
-20
lines changed

src/Migrate/Migrate.Autorest/custom/Get-AzMigrateLocalServerReplication.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ function Get-AzMigrateLocalServerReplication {
132132
)
133133

134134
process {
135-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1'
135+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonSettings.ps1")
136136
Import-Module $helperPath
137-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonHelper.ps1'
137+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonHelper.ps1")
138138
Import-Module $helperPath
139139

140140
$hasTargetObjectId = $PSBoundParameters.ContainsKey('TargetObjectID')

src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ function Initialize-AzMigrateLocalReplicationInfrastructure {
120120
)
121121

122122
process {
123-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1'
123+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonSettings.ps1")
124124
Import-Module $helperPath
125-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonHelper.ps1'
125+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonHelper.ps1")
126126
Import-Module $helperPath
127127

128128
CheckResourcesModuleDependency
@@ -586,32 +586,51 @@ function Initialize-AzMigrateLocalReplicationInfrastructure {
586586

587587
# amhStoredStorageAccount exists and in Succeeded state
588588
if ($null -ne $amhStoredStorageAccount -and
589-
$amhStoredStorageAccount.ProvisioningState -eq [StorageAccountProvisioningState]::Succeeded) {
589+
$amhStoredStorageAccount.ProvisioningState -eq [StorageAccountProvisioningState]::Succeeded)
590+
{
590591
# Use amhStoredStorageAccount and ignore user provided Cache Storage Account Id
591-
if (![string]::IsNullOrEmpty($CacheStorageAccountId) -and $amhStoredStorageAccount.Id -ne $CacheStorageAccountId) {
592+
if (![string]::IsNullOrEmpty($CacheStorageAccountId) -and $amhStoredStorageAccount.Id -ne $CacheStorageAccountId)
593+
{
592594
Write-Host "A Cache Storage Account '$($amhStoredStorageAccountName)' has been linked already. The given -CacheStorageAccountId '$($CacheStorageAccountId)' will be ignored."
593595
}
594596

595597
$cacheStorageAccount = $amhStoredStorageAccount
598+
599+
# This will fix brownfield issue where AMH solution tool is set incorrectly that causes UX bifurcation to go to the wrong experience;
600+
# for new projects that are set correctly from the start, this will essentially be a no-op.
601+
Az.Migrate.Internal\Set-AzMigrateSolution `
602+
-MigrateProjectName $ProjectName `
603+
-Name $amhSolution.Name `
604+
-ResourceGroupName $ResourceGroupName `
605+
-DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties `
606+
-Tool "ServerMigration_DataReplication" `
607+
-Purpose "Migration" | Out-Null
596608
}
597-
elseif ($null -eq $amhStoredStorageAccount -or $null -eq $amhStoredStorageAccount.ProvisioningState) {
609+
elseif ($null -eq $amhStoredStorageAccount -or $null -eq $amhStoredStorageAccount.ProvisioningState)
610+
{
598611
# amhStoredStorageAccount is found but in a bad state, so log to ask user to remove
599-
if ($null -ne $amhStoredStorageAccount -and $null -eq $amhStoredStorageAccount.ProvisioningState) {
612+
if ($null -ne $amhStoredStorageAccount -and $null -eq $amhStoredStorageAccount.ProvisioningState)
613+
{
600614
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."
601615
}
602616

603617
# amhStoredStorageAccount is not found or in a bad state but AMH has a record of it, so remove the record
604-
if ($amhSolution.DetailExtendedDetail.ContainsKey("replicationStorageAccountId")) {
618+
if ($amhSolution.DetailExtendedDetail.ContainsKey("replicationStorageAccountId"))
619+
{
605620
$amhSolution.DetailExtendedDetail.Remove("replicationStorageAccountId") | Out-Null
606621
$amhSolution.DetailExtendedDetail.Add("replicationStorageAccountId", $null) | Out-Null
622+
607623
Az.Migrate.Internal\Set-AzMigrateSolution `
608624
-MigrateProjectName $ProjectName `
609625
-Name $amhSolution.Name `
610626
-ResourceGroupName $ResourceGroupName `
611-
-DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties | Out-Null
627+
-DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties `
628+
-Tool "ServerMigration_DataReplication" `
629+
-Purpose "Migration" | Out-Null
612630
}
613631
}
614-
else {
632+
else
633+
{
615634
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."
616635
}
617636

@@ -928,13 +947,17 @@ function Initialize-AzMigrateLocalReplicationInfrastructure {
928947
}
929948

930949
# Update AMH record with chosen Cache Storage Account
931-
if (!$amhSolution.DetailExtendedDetail.ContainsKey("replicationStorageAccountId")) {
950+
if (!$amhSolution.DetailExtendedDetail.ContainsKey("replicationStorageAccountId"))
951+
{
932952
$amhSolution.DetailExtendedDetail.Add("replicationStorageAccountId", $cacheStorageAccount.Id)
953+
933954
Az.Migrate.Internal\Set-AzMigrateSolution `
934955
-MigrateProjectName $ProjectName `
935956
-Name $amhSolution.Name `
936957
-ResourceGroupName $ResourceGroupName `
937-
-DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties | Out-Null
958+
-DetailExtendedDetail $amhSolution.DetailExtendedDetail.AdditionalProperties `
959+
-Tool "ServerMigration_DataReplication" `
960+
-Purpose "Migration" | Out-Null
938961
}
939962

940963
Write-Host "*Selected Cache Storage Account: '$($cacheStorageAccount.StorageAccountName)' in Resource Group '$($ResourceGroupName)' at Location '$($cacheStorageAccount.Location)' for Migrate Project '$($migrateProject.Name)'"

src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateReplicationInfrastructure.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function Initialize-AzMigrateReplicationInfrastructure {
134134
Import-Module Az.Resources
135135
Import-Module Az.Storage
136136
Import-Module Az.RecoveryServices
137-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1'
137+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonSettings.ps1")
138138
Import-Module $helperPath
139139

140140
# Validate user specified target region

src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ function New-AzMigrateLocalServerReplication {
169169
)
170170

171171
process {
172-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1'
172+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonSettings.ps1")
173173
Import-Module $helperPath
174-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonHelper.ps1'
174+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonHelper.ps1")
175175
Import-Module $helperPath
176176

177177
CheckResourceGraphModuleDependency

src/Migrate/Migrate.Autorest/custom/Set-AzMigrateLocalServerReplication.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ function Set-AzMigrateLocalServerReplication {
128128
)
129129

130130
process {
131-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1'
131+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonSettings.ps1")
132132
Import-Module $helperPath
133-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonHelper.ps1'
133+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonHelper.ps1")
134134
Import-Module $helperPath
135135

136136
CheckResourcesModuleDependency

src/Migrate/Migrate.Autorest/custom/Start-AzMigrateLocalServerMigration.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ function Start-AzMigrateLocalServerMigration {
100100
)
101101

102102
process {
103-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonSettings.ps1'
103+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonSettings.ps1")
104104
Import-Module $helperPath
105-
$helperPath = Join-Path $PSScriptRoot 'Helper' 'AzLocalCommonHelper.ps1'
105+
$helperPath = [System.IO.Path]::Combine($PSScriptRoot, "Helper", "AzLocalCommonHelper.ps1")
106106
Import-Module $helperPath
107107

108108
CheckResourceGraphModuleDependency

src/Migrate/Migrate/ChangeLog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fixed bugs in `Initialize-AzMigrateLocalReplicationInfrastructure`
22+
- 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.
23+
* Address Join-Path compatibility issue in older version of PowerShell environment such as PowerShell 5.1 in the following commands
24+
- `Initialize-AzMigrateLocalReplicationInfrastructure`
25+
- `Initialize-AzMigrateReplicationInfrastructure`
26+
- `New-AzMigrateLocalServerReplication`
27+
- `Get-AzMigrateLocalServerReplication`
28+
- `Set-AzMigrateLocalServerReplication`
29+
- `Start-AzMigrateLocalServerMigration`
2130

2231
## Version 2.10.0
2332
* Fixed bugs in `New-AzMigrateLocalDiskMappingObject`: Only validate for non-512 physical sector size of VHD when `-PhysicalSectorSize` parameter is given

0 commit comments

Comments
 (0)