0
votes

I’ve created a VMSS in Azure with per-instance public IPs described here: https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-networking#creating-a-scale-set-with-public-ip-per-virtual-machine. I need a per-instance IP public IP configuration so that every individual instance is independently available from the outside.

Since there is apparently no way to specify a sku for such IPs (full format is here: https://docs.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachinescalesets#virtualmachinescalesetpublicipaddressconfigurationproperties-object), all IPs are always Standard. I can query public IPs as they are being created by VMSS, they are indeed Standard.

Metadata service (that I planned to use to get the IP from within the instance) only returns Basic public IPs (as stated here: https://docs.microsoft.com/en-us/azure/virtual-network/public-ip-addresses#standard).

How do I get the instance’s public IP from within the instance short of pinging a random 3rd party web site that returns the caller’s IP or talking to ARM from the instance?

1

1 Answers

0
votes

After my validation, you can get the instance’s public IP from within the instance refer to this sample. This also works to get the basic public IP from Azure VM.

Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET  -Uri "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/publicIpAddress?api-version=2017-08-01&format=text" | ConvertTo-Json

enter image description here

I create the VMSS with public IP in ARM template like this:

                                            "publicIPAddressconfiguration": {
                                                "name": "publicip",
                                                "properties": {
                                                "idleTimeoutInMinutes": 10,
                                                "dnsSettings": {
                                                    "domainNameLabel": "[parameters('vmssName')]"
                                                }
                                                }
                                            }