如何在Azure量表集中获取虚拟机的公共DNS名称
我使用Azure Portal的链接创建了使用VM量表集
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
,然后可以使用SSH进入该VM。
现在,我需要配置它,为此,我需要知道将哪些公共DNS记录分配给VM。我该怎么做?
我计划使用“用于Linux的自定义脚本”扩展程序运行VM的配置。
主机名
返回VM的计算机名称(例如MKVMSA524000001
),我需要拥有公共IP的完整DNS名称,例如vm1.myvmss.westeurope。 cloudapp.azure.com
(myVMSS从上面的命令中有vm-domain-name
arg)。
如果有帮助 - 我正在使用基于Linux的图像。
我可以使用实例的公共IP地址,
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"
但是如何获得其名称,例如vm-01
?然后我可以手动添加后缀
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这篇文章找到了一个选项 - https://msftstack.wordpress.com/2017/05/05/10/figuring-ob-azure-vm-scale-scale-scale-set-machine-names/
来自VM的主机名,有可能获得比例集中的索引:
可以使用$(主机名)找到主机名,然后将DNS名称构建为
Found an option based on this post - https://msftstack.wordpress.com/2017/05/10/figuring-out-azure-vm-scale-set-machine-names/
From the hostname of the VM it is possible to get the index of it in the Scale Set:
Host name can be found using $(hostname) and then build DNS name as