Azure / Azure/azure-powershell
Inconsistent behavior with the PrivateIpAddress parameter on New-AzNetworkInterfaceIpConfig
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
## Description
When no subnet is provided, `New-AzNetworkInterfaceIpConfig` simply ignores the `-PrivateIpAddress` parameter. There's no error message, it's simply not applied. However, any requirement to to ensure a subnet is specified when setting a private IP can be easily circumvented by setting the field after the fact:
```pwsh
$cfg=New-AzNetworkInterfaceIpConfig -Name 'myconfig' -PrivateIpAddress '10.0.6.66'
# Private IP not set here.
$cfg.PrivateIpAddress='10.0.6.66'
# But now it is
```
If IP address must not be set without a subnet present, then conditional logic needs to be able to the setter of `Microsoft.Azure.Commands.Network.Models.PSNetworkInterfaceIPConfiguration` to enforce this constraint. If not, then it should not be disregarded in `New-AzNetworkInterfaceIpConfig`.
## Steps to reproduce
See above
## Environment data
```
Name Value
---- -----
PSVersion 6.2.3
PSEdition Core
GitCommitId 6.2.3
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
## Module versions
```powershell
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.15.0 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Ad…
```
Contributor guide
Research direction
Start by reproducing the behavior with New-AzNetworkInterfaceIpConfig using -PrivateIpAddress without a subnet. Then inspect the command and Microsoft.Azure.Commands.Network.Models.PSNetworkInterfaceIPConfiguration setter behavior. Done means the parameter is either applied consistently or rejected with a clear error, with coverage for both paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, powershell
- Domain
- cloud, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100