我正在上课,并且坚持了将近一个星期。我创建了一个VM,现在它希望我将IP config方法更改为static。确切的词是。
“您已经在第二步中创建了一个ubuntu虚拟机,在其中检查公用IP(publicIpAllocationMethod)地址,并通过执行azure CLI命令将其更改为静态。”
我使用以下命令创建了VM。 az vm create -n MyVm1 -g groupname --admin-username“ n1234” --admin-password“ nk123 @ 9090” --location westUS --image UbuntuLTS
使用以下命令获得VM NIC。 nic_id = $(az vm show -g gropname -n MyVm1 -d --query networkProfile.networkInterfaces [0] .id) az network nic show --ids MyVm1VMNic
我具有VM的IP,但不确定如何将其更改为静态。
答案 0 :(得分:1)
我通过使用以下命令解决了该问题。
az network public-ip update -g GROUPNAME -n MyVm1PublicIP --allocation-method Static
答案 1 :(得分:0)
您要查找的内容可以在这里找到:https://docs.microsoft.com/en-us/cli/azure/network/nic/ip-config?view=azure-cli-latest#az-network-nic-ip-config-update
以您的示例为例,您将运行以下命令:
nic_id=$(az vm show -g gropname -n MyVm1 -d --query
networkProfile.networkInterfaces[0].id --output tsv)
nicName=$(az network nic show --ids $nic_id --query name --output tsv)
ipconfig=$(az network nic show --ids $nic_id --query ipConfigurations[0].name
--output tsv)
az network nic ip-config update -g gropname --nic-name $nicName -n $ipconfig --private-ip-address <static ip address>
通过设置专用IP,IP配置将更新为静态。上面的代码依赖于具有单个NIC的VM,这是根据您的示例假定的。
希望有帮助!