-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[Az.Migrate] Add validation for HA, storagepath, storageaccount, and bug fix #29414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
19c6594
923c5ad
077f09a
7846bad
bd3fcb8
1adb9d2
04b81df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,9 +177,6 @@ function New-AzMigrateLocalServerReplication { | |
| CheckResourceGraphModuleDependency | ||
| CheckResourcesModuleDependency | ||
|
|
||
| $HasMachineId = $PSBoundParameters.ContainsKey('MachineId') | ||
| $HasTargetStoragePathId = $PSBoundParameters.ContainsKey('TargetStoragePathId') | ||
| $HasTargetResourceGroupId = $PSBoundParameters.ContainsKey('TargetResourceGroupId') | ||
| $HasTargetVMCPUCore = $PSBoundParameters.ContainsKey('TargetVMCPUCore') | ||
| $HasIsDynamicMemoryEnabled = $PSBoundParameters.ContainsKey('IsDynamicMemoryEnabled') | ||
| if ($HasIsDynamicMemoryEnabled) { | ||
|
|
@@ -212,22 +209,22 @@ function New-AzMigrateLocalServerReplication { | |
| $null = $PSBoundParameters.Add('ErrorAction', 'SilentlyContinue') | ||
|
|
||
| # Validate ARM ID format from inputs | ||
| if ($HasMachineId -and !(Test-AzureResourceIdFormat -Data $MachineId -Format $IdFormats.MachineArmIdTemplate)) | ||
| if (!(Test-AzureResourceIdFormat -Data $MachineId -Format $IdFormats.MachineArmIdTemplate)) | ||
| { | ||
| throw New-InvalidResourceIdProvidedException ` | ||
| -ResourceId $MachineId ` | ||
| -ResourceType "DiscoveredMachine" ` | ||
| -Format $IdFormats.MachineArmIdTemplate | ||
| } | ||
|
|
||
| if ($HasTargetStoragePathId -and !(Test-AzureResourceIdFormat -Data $TargetStoragePathId -Format $IdFormats.StoragePathArmIdTemplate)) { | ||
| if (!(Test-AzureResourceIdFormat -Data $TargetStoragePathId -Format $IdFormats.StoragePathArmIdTemplate)) { | ||
| throw New-InvalidResourceIdProvidedException ` | ||
| -ResourceId $TargetStoragePathId ` | ||
| -ResourceType "StorageContainer" ` | ||
| -Format $IdFormats.StoragePathArmIdTemplate | ||
| } | ||
|
|
||
| if ($HasTargetResourceGroupId -and !(Test-AzureResourceIdFormat -Data $TargetResourceGroupId -Format $IdFormats.ResourceGroupArmIdTemplate)) { | ||
| if (!(Test-AzureResourceIdFormat -Data $TargetResourceGroupId -Format $IdFormats.ResourceGroupArmIdTemplate)) { | ||
| throw New-InvalidResourceIdProvidedException ` | ||
| -ResourceId $TargetResourceGroupId ` | ||
| -ResourceType "ResourceGroup" ` | ||
|
|
@@ -651,6 +648,34 @@ function New-AzMigrateLocalServerReplication { | |
| $customProperties.FabricDiscoveryMachineId = $machine.Id | ||
| $customProperties.RunAsAccountId = $runAsAccountId | ||
| $customProperties.SourceFabricAgentName = $sourceDra.Name | ||
|
|
||
| # Validate storage path exists and is in a usable state | ||
| $storagePath = Get-AzResource ` | ||
| -ResourceId $TargetStoragePathId ` | ||
| -ErrorVariable notPresent ` | ||
| -ErrorAction SilentlyContinue | ||
| if ($null -eq $storagePath) { | ||
| throw "Storage path with Id '$TargetStoragePathId' not found. Please provide a valid storage path ARM ID." | ||
| } | ||
|
|
||
| # Creation must have succeeded for the storage path to be usable | ||
| $creationStatus = $storagePath.Properties.status.provisioningStatus.status | ||
| if ([string]::IsNullOrEmpty($creationStatus)) { | ||
| throw "Storage path '$($storagePath.Name)' creation status is unavailable. Please verify the storage path resource is fully provisioned." | ||
| } | ||
| if ($creationStatus -ne "Succeeded") { | ||
| throw "Storage path '$($storagePath.Name)' has a creation provisioning status of '$creationStatus'. Only storage paths with a successful creation can be used. Please select a different storage path or wait for provisioning to complete." | ||
| } | ||
|
|
||
| # The latest operation (ProvisioningState) must also be Succeeded | ||
| $provisioningState = $storagePath.Properties.provisioningState | ||
| if ([string]::IsNullOrEmpty($provisioningState)) { | ||
| throw "Storage path '$($storagePath.Name)' provisioning state is unavailable. Please verify the storage path resource is fully provisioned." | ||
| } | ||
| if ($provisioningState -ne "Succeeded") { | ||
| throw "Storage path '$($storagePath.Name)' has a provisioning state of '$provisioningState'. Only storage paths with a 'Succeeded' provisioning state can be used. Please resolve the issue or select a different storage path." | ||
|
Comment on lines
+652
to
+676
|
||
| } | ||
|
|
||
| $customProperties.StorageContainerId = $TargetStoragePathId | ||
| $customProperties.TargetArcClusterCustomLocationId = $arbArgResult.CustomLocation | ||
| $customProperties.TargetFabricAgentName = $targetDra.Name | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,12 @@ | |
| - Additional information about change #1 | ||
| --> | ||
| ## Upcoming Release | ||
| * Fixed bugs in `Initialize-AzMigrateLocalReplicationInfrastructure` | ||
| - Added early Azure login validation with a clear error message when user is not logged in | ||
| - Removed unnecessary caller identity resolution | ||
| - Added cache storage account validations to reject unsupported SKU tiers and disabled public network access | ||
|
Comment on lines
+21
to
+24
|
||
| * Updated `New-AzMigrateLocalServerReplication` | ||
| - Added storage path health validation before initiating replication | ||
|
|
||
| ## Version 2.11.0 | ||
| * Updated DefaultCrashConsistentFrequencyInMinutes and DefaultAppConsistentFrequencyInMinutes to align with Azure Portal UX for Replication Policy | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New cache storage account validations (SKU tier and PublicNetworkAccess) are added here, but the existing Pester tests for this cmdlet only cover the happy path. Please add test cases that exercise these failure modes (e.g., Premium tier and PublicNetworkAccess Disabled) so the new validation behavior doesn’t regress.