I created VM Scale Set using
az vmss create -n XXX -g XXX --image XXX --public-ip-per-vm --vm-domain-name myvmss --vm-sku Standard_B1s --instance-count 1 --admin-password XXX --admin-username XXX--authentication-type password
And then I am able to ssh into that VM using a link from azure portal.
Now I need to configure it and for that I need to know what public DNS record was assigned to VM. How can I do it?
I plan to run the configuration of the VMs using "Custom Script For Linux" extension.
hostname
returns the computer name of the VM (e.g. mkvmsa524000001
) and I need to have the full DNS name of the public IP, e.g. vm1.myvmss.westeurope.cloudapp.azure.com
(myvmss there is the vm-domain-name
arg from the command above).
If it helps - I am using Linux based image.
I can get the public IP address of the instance using
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/publicIpAddress?api-version=2017-08-01&format=text"
But how to get its name, e.g. vm-01
? I could add the suffix manually then