I have a VM NIC that has an IP(Primary) added to it. I am trying to find a way how I can add more IP's to the NIC.I am using a piece of code and it throws an error saying.
The final solution should actually give me to add 4 ip additonal to the NIC and update the first Ip which is primary and also update dns ip to the NIC.
Error Thrown: nic1-test-ipConfig cannot be deleted. Deletion and renaming of primary IP Configuration is not supported StatusCode: 400 ReasonPhrase: Bad Request ErrorCode: IpConfigDeleteNotSupported ErrorMessage: IP Configuration ProdNuma1-nic1-test-ipConfig cannot be deleted.
$vnet = Get-AzVirtualNetwork -Name "vnet" -ResourceGroupName "rg"
$subnet1 = Get-AzVirtualNetworkSubnetConfig -Name "sn" -VirtualNetwork $vnet
$location="westcentralus"
$vm="test"
#Adding IP's to ->NIC1
$ipc11 = New-AzNetworkInterfaceIpConfig -Name "ipconfig1" -PrivateIpAddress "10.64.13.10" -Primary -Subnet $subnet1
$ipc12 = New-AzNetworkInterfaceIpConfig -Name "ipconfig2" -PrivateIpAddress "10.64.13.11" -Subnet $subnet1
$ipc13 = New-AzNetworkInterfaceIpConfig -Name "ipconfig3" -PrivateIpAddress "10.64.13.12" -Subnet $subnet1
$ipc14 = New-AzNetworkInterfaceIpConfig -Name "ipconfig4" -PrivateIpAddress "10.64.13.13" -Subnet $subnet1
$ipc15 = New-AzNetworkInterfaceIpConfig -Name "ipconfig5" -PrivateIpAddress "10.64.13.14" -Subnet $subnet1
$NIC1 = New-AzNetworkInterface -Name "nic1-test" -ResourceGroupName "rg" -force -Location $location -IpConfiguration $ipc12,$ipc13,$ipc14,$ipc15 -DnsServer "10.64.2.00","10.64.0.01"