Skip to content

[Az.Migrate] Add validation for HA, storagepath, storageaccount, and bug fix#29414

Open
minhsuanlee wants to merge 7 commits intoAzure:mainfrom
minhsuanlee:user/samlee3/validation-bug-fixes
Open

[Az.Migrate] Add validation for HA, storagepath, storageaccount, and bug fix#29414
minhsuanlee wants to merge 7 commits intoAzure:mainfrom
minhsuanlee:user/samlee3/validation-bug-fixes

Conversation

@minhsuanlee
Copy link
Copy Markdown
Contributor

@minhsuanlee minhsuanlee commented Apr 16, 2026

Description

Add validation for HA, storagepath, storageaccount, and bug fix for caller identity resolution for Service Principal and Managed Identity

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Copilot AI review requested due to automatic review settings April 16, 2026 19:04
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional runtime validation and error handling for AzLocal migration/replication flows in Az.Migrate to prevent misconfiguration (HA state, storage path, and cache storage account settings) and improves caller identity resolution.

Changes:

  • Tightens replication pre-checks around Hyper-V HA status (including an explicit “Unknown” path).
  • Adds storage path existence/state validation during New-AzMigrateLocalServerReplication.
  • Updates Initialize-AzMigrateLocalReplicationInfrastructure to resolve caller identity across user/SP/managed identity and adds cache storage account validations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 Makes ARM ID validation unconditional and adds storage path existence/provisioning checks before starting replication.
src/Migrate/Migrate.Autorest/custom/Initialize-AzMigrateLocalReplicationInfrastructure.ps1 Updates caller identity resolution logic and adds cache storage account validation (SKU and access settings).
src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonSettings.ps1 Extends HA constants/messages to include an “Unknown” state and improved wording.
src/Migrate/Migrate.Autorest/custom/Helper/AzLocalCommonHelper.ps1 Enhances replication prerequisites to treat clustered Hyper-V VMs with unknown HA status as invalid.

Comment thread src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 Outdated
@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copilot AI review requested due to automatic review settings April 16, 2026 21:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 Outdated
Comment thread src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 Outdated
@minhsuanlee minhsuanlee added this to the Az 15.6.0 (05/05/2026) milestone Apr 16, 2026
@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@github-actions
Copy link
Copy Markdown

‼️ DO NOT MERGE THIS PR ‼️
This PR was labeled "Do Not Merge" because it contains code change that cannot be merged. Please contact the reviewer for more information.

1 similar comment
@github-actions
Copy link
Copy Markdown

‼️ DO NOT MERGE THIS PR ‼️
This PR was labeled "Do Not Merge" because it contains code change that cannot be merged. Please contact the reviewer for more information.

@minhsuanlee
Copy link
Copy Markdown
Contributor Author

minhsuanlee commented Apr 17, 2026

Validating changed scenarios:

  1. [passed] Storage account has "Public Network Access" Disabled - should result in failure
image 2. [passed] Storage path check in `New-AzMigrateLocalServerReplication` image

@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copilot AI review requested due to automatic review settings April 17, 2026 21:04
@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread src/Migrate/Migrate.Autorest/custom/New-AzMigrateLocalServerReplication.ps1 Outdated
@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copilot AI review requested due to automatic review settings April 17, 2026 21:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment on lines +21 to +24
* 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
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog entry mentions "Removed unnecessary caller identity resolution", but the PR description calls out a bug fix for caller identity resolution specifically for Service Principal and Managed Identity. Consider updating this entry to describe the user-visible impact (e.g., initialization now works reliably when logged in with a service principal or managed identity) so release notes match the stated fix.

Copilot uses AI. Check for mistakes.
Comment on lines +776 to +785
# Validate Cache Storage Account SKU tier is Standard (not Premium)
if ($cacheStorageAccount.Sku.Tier -ne "Standard") {
throw "Cache Storage Account '$($cacheStorageAccount.StorageAccountName)' uses an unsupported SKU tier '$($cacheStorageAccount.Sku.Tier)'. Only 'Standard' tier storage accounts are supported. Please provide a Standard tier storage account."
}

# Validate public network access should not be disabled even for private endpoint
if (![string]::IsNullOrEmpty($cacheStorageAccount.PublicNetworkAccess) -and
$cacheStorageAccount.PublicNetworkAccess -eq "Disabled") {
throw "Cache Storage Account '$($cacheStorageAccount.StorageAccountName)' does not allow public network access. Please enable 'Public network access' on the storage account and re-run this command."
}
Copy link

Copilot AI Apr 17, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +652 to +676
# 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."
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storage path health validation is newly introduced here, but the Pester tests for New-AzMigrateLocalServerReplication are currently skipped and don’t cover these new error paths. Please add/enable tests that validate behavior for (1) non-existent storage path id and (2) non-succeeded provisioning states, ideally using playback recordings/mocking.

Copilot uses AI. Check for mistakes.
@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants