[Network] az network virtual-appliance migration: --migration-type is optional - #34065
[Network] az network virtual-appliance migration: --migration-type is optional#34065Graves (Jordang3177) wants to merge 1 commit into
az network virtual-appliance migration: --migration-type is optional#34065Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Null-body serialization and migration-option validation issues remain, with related test coverage gaps.
Pull request overview
Updates NVA migration commands to support omitted --migration-type and null request bodies for ILB migrations while preserving explicit OS migration requests.
Changes:
- Makes migration type optional for prepare, execute, and commit.
- Updates unit and live tests for null-body workflows.
- Preserves explicit migration payload support.
File summaries
| File | Review |
|---|---|
src/azure-cli/azure/cli/command_modules/network/tests/latest/test_network_unit_tests.py |
Nit (1): Add coverage asserting marketPlaceVersion for explicit OS migration. |
src/azure-cli/azure/cli/command_modules/network/tests/latest/test_network_commands.py |
Exercises the ILB migration workflow without --migration-type. |
src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_prepare.py |
Moderate (1): Required command arguments can cause { "properties": {} } instead of a null body. Moderate (1): Reject marketplace version without an OS migration type. Nit (1): Add combined OS migration and marketplace-version coverage. |
src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_execute.py |
Moderate (1): Required command arguments can cause { "properties": {} } instead of a null body. |
src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_commit.py |
Moderate (1): Required command arguments can cause { "properties": {} } instead of a null body. |
Review details
Suppressed comments (6)
src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_commit.py:179
- With a real invocation,
ctx.argsalso contains the requirednetwork_virtual_appliance_nameandresource_group. Becauseset_prop("properties", ...)runs before this mapping, the root builder becomes non-empty even whenmigration_typeis undefined, soserialize_contentsends{"properties": {}}instead ofNone; the new unit test's empty context misses this. Gate creation ofpropertieson the migration field (and test with the required-n/-garguments) so the documented null-body flow actually sends no body.
properties.set_prop("migrationType", AAZStrType, ".migration_type")
src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_execute.py:179
- With a real invocation,
ctx.argsalso contains the requirednetwork_virtual_appliance_nameandresource_group. Becauseset_prop("properties", ...)runs before this mapping, the root builder becomes non-empty even whenmigration_typeis undefined, soserialize_contentsends{"properties": {}}instead ofNone; the new unit test's empty context misses this. Gate creation ofpropertieson the migration field (and test with the required-n/-garguments) so the documented null-body flow actually sends no body.
properties.set_prop("migrationType", AAZStrType, ".migration_type")
src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_prepare.py:185
- This relaxation also affects
preparewhen--marketplace-versionis supplied, but the new test only exercises a type-only body. Please add aPreparecase withMigrateToNewOSVersionplus a marketplace version and assert bothmigrationTypeandmarketPlaceVersion; otherwise a regression in that request mapping would go unnoticed.
properties.set_prop("migrationType", AAZStrType, ".migration_type")
src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_prepare.py:185
- With a real invocation,
ctx.argsalso contains the requirednetwork_virtual_appliance_nameandresource_group. Becauseset_prop("properties", ...)runs before this mapping, the root builder becomes non-empty even when both migration fields are undefined, soserialize_contentsends{"properties": {}}instead ofNone; the new unit test's empty context misses this. Gate creation ofpropertieson the migration fields (and test with the required-n/-garguments) so the documented null-body flow actually sends no body.
properties.set_prop("migrationType", AAZStrType, ".migration_type")
src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/virtual_appliance/migration/_prepare.py:68
- Making
--migration-typeoptional also permitsprepare --marketplace-version <version>by itself. This then builds{"properties": {"marketPlaceVersion": ...}}rather than the null body used for the ILB default, even though the help says this option only applies toMigrateToNewOSVersion; the service can therefore receive an ambiguous or invalid migration request. Please reject this combination, or require the OS migration type whenever--marketplace-versionis set, before serialization.
help="The type of migration workflow to prepare for the Network Virtual Appliance. If omitted, the migration defaults to MigrateToNewILBArchitecture.",
src/azure-cli/azure/cli/command_modules/network/tests/latest/test_network_unit_tests.py:54
- The explicit-body test only sets
migration_type; it never suppliesmarketplace_versionor checksmarketPlaceVersioninPrepare's payload. That is the prepare-specific OS migration option advertised by this PR, so a regression in its serialization would pass these tests. Add a Prepare-only case with both values and assert both serialized properties.
'migration_type': 'MigrateToNewOSVersion',
})
operation = object.__new__(operation_type)
operation.ctx = ctx
self.assertEqual(operation.content, {
- Files reviewed: 5/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
az network virtual-appliance migration Body is Optional for NVA's Migration
|
Network |
az network virtual-appliance migration Body is Optional for NVA's Migrationaz network virtual-appliance migration: --migration-type is optional
|
Graves (@Jordang3177) better to have a new recording. |
🤖 PR Validation —⚠️ Review suggested
Related command
az network virtual-appliance migration prepareaz network virtual-appliance migration executeaz network virtual-appliance migration commitDescription
Updates the Network Virtual Appliance ILB migration flow to support a null request body.
--migration-typeis now optional for theprepare,execute, andcommitcommands. When omitted, Azure CLI sends no request body and the service defaults the migration type toMigrateToNewILBArchitecture.Explicitly specifying
--migration-typeremains supported for other workflows such asMigrateToNewOSVersion.Related AAZ PR: Azure/aaz#1088
Original Azure CLI PR: #33766
Testing Guide
Run an ILB migration without specifying
--migration-type:Verify the provisioning state between phases:
az network virtual-appliance show \ --resource-group MyResourceGroup \ --name MyNva \ --query provisioningStateThe existing explicit request-body flow remains supported:
az network virtual-appliance migration prepare \ --resource-group MyResourceGroup \ --name MyNva \ --migration-type MigrateToNewOSVersion \ --marketplace-version <version>Automated tests verify that:
--migration-typeis optional for all three phases.None.History Notes
[Network]
az network virtual-appliance migration: Allow ILB migration commands to omit--migration-typeThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.