简体   繁体   中英

Can I get the public IP of a Virtual Machine Scale Set using Azure REST API?

I have a AKS cluster and I want to get the public IP of the virtual machine scale set associated with the cluster's agentpool. I found this documentation page and tried the following API call:

GET https://management.azure.com/subscriptions/{your sub ID}/resourceGroups/{RG name}/providers/Microsoft.Compute/virtualMachineScaleSets/{scale set name}/publicipaddresses?api-version=2017-03-30

but i get this response: {"value":[]}

By default the virtual machine scale set of AKS doesn't have public IP. AKS nodes do not require their own public IP addresses for communication.

But you can assign a public IP per node(preview mode).

Here is the link to official documentation:

https://docs.microsoft.com/en-us/azure/aks/use-multiple-node-pools#assign-a-public-ip-per-node-for-your-node-pools-preview

You can validate whether the publicipaddresses key of your scale set contains any values by visiting https://resources.azure.com/ and navigating to the scale set. It is entirely possible that your VMSS has no public IPs associated with the VMs.

For your issue, you need to take care of the message that how does the VMSS create:

To create a scale set that assigns a public IP address to each virtual machine with the CLI, add the --public-ip-per-vm parameter to the vmss create command.

Only in this way you can get the public IP addresses via the REST API:

GET https://management.azure.com/subscriptions/{your sub ID}/resourceGroups/{RG name}/providers/Microsoft.Compute/virtualMachineScaleSets/{scale set name}/publicipaddresses?api-version=2017-03-30

But when you create the AKS cluster and enable the VMSS as the agent pool, the VMSS always behind in a Load Balancer so that it's publicIpAddressConfiguration property is null and give your response as empty.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM