Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 `
-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."
}

Expand Down Expand Up @@ -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)'"
Expand Down
2 changes: 2 additions & 0 deletions src/Migrate/Migrate/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
Expand Down