Getting Scale Set Private IPs is Hard
I have found that it is impressively difficult to get the private IP addresses of Azure scale set instances in almost every tool.
For example, if you go and create a scale set in Terraform, even Terraform will not provide you the addresses or a way to look them up to act upon them in future steps. Similarly, you cannot easily list the addresses in Ansible.
You can make dynamic inventories in Ansible based on scripts though. So, in order to make an ansible playbook target the nodes in a recently created scale set dynamically, I decided to use a dynamic inventory created by the Azure CLI.
Azure CLI Command
Here is an azure CLI command (version 2.0.58) which directly lists the IP addresses of scale set nodes. I hope it helps you as it has helped me. It took a while to build it out from the docs but its pretty simple now that it’s done.
az vmss nic list --resource-group YourRgName \ --vmss-name YourVmssName \ --query ".ipConfigurations.privateIpAddress"
The output will look similar to this, though I just changed the IP addresses to fake ones here an an example.
[ "184.108.40.206", "220.127.116.11" ]