Azure VM InternalDnsSuffix

Azure VM InternalDnsSuffix

当您在 Azure 中创建一个 VM 并通过 ssh 连接到它时,运行 'hostname -f' 您会得到一个格式为 "vmname.InternalDnsSuffix" 的主机名。是否有 programatic/scriptable 方法来获取 ResourceGroup/Subscription/Subnet 的 InternalDnsSuffix?我知道我可以为 运行ning VM 获取它,但是对于已停止的 VM,我从哪里获取它?有什么方法可以让我只为一组 VM 获取一次,而不是独立查询每个 VM?

Is there a programatic/scriptable way to get InternalDnsSuffix for a ResourceGroup/Subscription/Subnet?

该属性仅关联到 Azure VM,因此您应该从该 VM 获取此信息。

您可以使用 Azure REST API 到 运行 hostname -f 命令从 运行ning 虚拟机获取内部 DNS 后缀:

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand?api-version=2017-03-30

有关通过 REST API 命令的 运行 的更多信息,请参阅此 article

据我所知,我们无法从已停止的 VM 获取 dns 后缀或为一组获取一次内部 dns 后缀。