Preconditions
Related command
az network vnet update
Resource Provider
Microsoft.Network
Description of Feature or Work Requested
For command, az network vnet update the parameters --address-prefixes and --ipam-pool-prefix-allocations are mutually exclusive; only one can be provided at a time.
Expectation/Feature Request:
- Allow empty array for param --ipam-pool-prefix-allocations. Empty array is valid input.
- If both are provided, and the pool param is a non-empty array, then use ipam pool as is and set address prefixes to an empty array.
- If both are provided, and the ipam pool is an empty array, use the address prefix and pool as is.
For example (note: syntax for powershell):
az network vnet update -n "testing" -g "test-rg" --address-prefixes "['10.0.0.0/16']" --ipam-pool-prefix-allocations '[]'
this command should be valid and interpreted as updating vnet to use the specified address prefixes and removing any association with an IPAM pool. That is, request should include the address prefixes and pool params as is.
Issue:
The issue seems to be in custom.py, line #L5578:
Code snippet:
if has_value(args.ipam_pool_prefix_allocations):
args.address_prefixes = []
This current logic works for the create command but causes issues for the update command. During an update, we might need to remove an existing pool assignment (indicated by empty array) and use the provided --address-prefixes. Currently, If --ipam-pool-prefix-allocations is provided, even as an empty array, it sets --address-prefixes to an empty array. This is not the expected behavior. The current custom.py logic sets both to empty arrays, resulting in a (400 client error) because both cannot be null.
Other examples:
az network vnet update -n "testing" -g "test-rg" --address-prefixes '[]' --ipam-pool-prefix-allocations '[{\"NumberOfIpAddresses\": \"100\", \"Id\": \"/subscriptions/dfa8d777-26f3-4e5e-be19-d6d5fa3176fc/resourceGroups/ipam-test-rg/providers/Microsoft.Network/networkManagers/satalrejtestnm1/ipamPools/danlope-pool2\"}]'
this command should be valid and interpreted as updating vnet to use the ipam pool. Request should include the address prefixes and pool params as is.
az network vnet update -n "testing" -g "test-rg" --address-prefixes "['10.0.0.0/16']" --ipam-pool-prefix-allocations '[{\"NumberOfIpAddresses\": \"100\", \"Id\": \"/subscriptions/dfa8d777-26f3-4e5e-be19-d6d5fa3176fc/resourceGroups/ipam-test-rg/providers/Microsoft.Network/networkManagers/satalrejtestnm1/ipamPools/danlope-pool2\"}]'
If both address prefixes and IPAM pool are provided as non-empty arrays, the command should prioritize the IPAM pool and request should include the address prefixes as empty array and the pool params as is.
Minimum API Version Required
2024-05-01
Swagger PR link / SDK link
https://github.com/Azure/azure-rest-api-specs/blob/877f166d9819e61625338a9ebb9922e1fc646636/specification/network/resource-manager/Microsoft.Network/stable/2024-05-01/virtualNetwork.json#L158
Request Example
https://github.com/Azure/azure-rest-api-specs/blob/main/specification/network/resource-manager/Microsoft.Network/stable/2024-05-01/examples/VirtualNetworkCreateWithIpamPool.json
Target Date
2025-4-25
PM Contact
LIJAY
Engineer Contact
DANLOPE
Additional context
No response
Preconditions
Related command
az network vnet update
Resource Provider
Microsoft.Network
Description of Feature or Work Requested
For command,
az network vnet updatethe parameters--address-prefixesand--ipam-pool-prefix-allocationsare mutually exclusive; only one can be provided at a time.Expectation/Feature Request:
For example (note: syntax for powershell):
az network vnet update -n "testing" -g "test-rg" --address-prefixes "['10.0.0.0/16']" --ipam-pool-prefix-allocations '[]'this command should be valid and interpreted as updating vnet to use the specified address prefixes and removing any association with an IPAM pool. That is, request should include the address prefixes and pool params as is.
Issue:
The issue seems to be in custom.py, line #L5578:
Code snippet:
This current logic works for the create command but causes issues for the update command. During an update, we might need to remove an existing pool assignment (indicated by empty array) and use the provided --address-prefixes. Currently, If --ipam-pool-prefix-allocations is provided, even as an empty array, it sets --address-prefixes to an empty array. This is not the expected behavior. The current custom.py logic sets both to empty arrays, resulting in a (400 client error) because both cannot be null.
Other examples:
az network vnet update -n "testing" -g "test-rg" --address-prefixes '[]' --ipam-pool-prefix-allocations '[{\"NumberOfIpAddresses\": \"100\", \"Id\": \"/subscriptions/dfa8d777-26f3-4e5e-be19-d6d5fa3176fc/resourceGroups/ipam-test-rg/providers/Microsoft.Network/networkManagers/satalrejtestnm1/ipamPools/danlope-pool2\"}]'this command should be valid and interpreted as updating vnet to use the ipam pool. Request should include the address prefixes and pool params as is.
az network vnet update -n "testing" -g "test-rg" --address-prefixes "['10.0.0.0/16']" --ipam-pool-prefix-allocations '[{\"NumberOfIpAddresses\": \"100\", \"Id\": \"/subscriptions/dfa8d777-26f3-4e5e-be19-d6d5fa3176fc/resourceGroups/ipam-test-rg/providers/Microsoft.Network/networkManagers/satalrejtestnm1/ipamPools/danlope-pool2\"}]'If both address prefixes and IPAM pool are provided as non-empty arrays, the command should prioritize the IPAM pool and request should include the address prefixes as empty array and the pool params as is.
Minimum API Version Required
2024-05-01
Swagger PR link / SDK link
https://github.com/Azure/azure-rest-api-specs/blob/877f166d9819e61625338a9ebb9922e1fc646636/specification/network/resource-manager/Microsoft.Network/stable/2024-05-01/virtualNetwork.json#L158
Request Example
https://github.com/Azure/azure-rest-api-specs/blob/main/specification/network/resource-manager/Microsoft.Network/stable/2024-05-01/examples/VirtualNetworkCreateWithIpamPool.json
Target Date
2025-4-25
PM Contact
LIJAY
Engineer Contact
DANLOPE
Additional context
No response