az vmss update 用于更新 DNS

az vmss update for updating the DNS

我在 Azure 上有一个 VMSS,我需要更改它的 DNS 服务器。我为此找到了 Azure CLI 命令,但我无法弄清楚它的最终形式。 这是我的:

az vmss update -n myVmss --set virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].dnsSettings

我做错了什么?

az vmss update -n myVmss --set virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].dnsSettings='{"dnsServers":["10.0.0.5", "10.0.0.6"]}'

如果您使用 --set,您需要提供整个对象。您可能需要转义双引号。

...dnsSettings="{\"dnsServers\":[\"10.0.0.5\", \"10.0.0.6\"]}"

如果 DNS 设置对象不为空,您也可以这样做:

az vmss update -n myVmss --add virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].dnsSettings.dnsServers "10.0.0.5"