Daniel
Daniel

Reputation: 549

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":[]}

Upvotes: 0

Views: 1770

Answers (3)

Charles Xu
Charles Xu

Reputation: 31414

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.

Upvotes: 1

bpdohall
bpdohall

Reputation: 1051

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.

Upvotes: 2

Alex0M
Alex0M

Reputation: 91

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://learn.microsoft.com/en-us/azure/aks/use-multiple-node-pools#assign-a-public-ip-per-node-for-your-node-pools-preview

Upvotes: 2

Related Questions