I have a requirement to update/set public IP address of VMScaleset instances from a given IpPublicPrefix(for customer to whitelist these IPs). I've tried creating VMScaleset with two instances (with a Virtual Network, SubNet, Network Interface) and PublicIpPrefix but the code suggested from Azure doc is not working at all. https://learn.microsoft.com/en-us/powershell/module/azurerm.network/set-azurermnetworkinterface?view=azurermps-6.13.0
First issue: below code does not return the Network Interface I created above. Is this bug in Azure API?
Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
It only returns list of Network Interfaces which were created for VM(created not from VMSS), it does not include Network Interface which were created during VMSS creation.
Second Issue: Per some comments here and there, NetworkInterface for VMSS will not display in Azure Portal (search for Network Interfaces) nor AzureRM API then how do we suppose to know and update NIC for a VMSS or its instances?
I have been using AzureRm module 6.13.1
For the first issue, the public IP of the scale set instances is not a separate resource in the Azure portal, we can not use
Get-AzureRmNetworkInterface
to get the network interface information.For the second issue, you can create a scale set with public IP per virtual machine by ARM template. You can add a publicIpAddressConfiguration JSON property to the scale set ipConfigurations section.
Note that IpPublicPrefix requires a standard SKU load balancer and public IP address. Here is a working sample.
Also, you can get the specified public IP address of an instance in a virtual machine scale set with the REST API.