Skip to content

Commit 83437fa

Browse files
author
Sam Lee
committed
Fix AMH solution tool ServerMigration_DataReplication
1 parent e9a75c4 commit 83437fa

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

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

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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 bifracation to go to the wrong experience;
600+
# for new projects that are set correctly from the start, this will essentailly 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/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* Fixed bugs in `Get-AzMigrateLocalServerReplication`
3030
- Added ARM id validation for input parameters
3131
* Enhanced Get-AzMigrateServerMigrationStatus to add support for the -Expedite parameter.
32+
* Fixed bugs in `Initialize-AzMigrateLocalReplicationInfrastructure`
33+
- 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.
3234

3335
## Version 2.9.0
3436
* Added `-OsType` as an optional parameter to command `Set-AzMigrateLocalServerReplication` to allow user-specified OS type.

0 commit comments

Comments
 (0)