azure cli 2.0如何添加inbound-nat-rule?

azure cli 2.0 how to add inbound-nat-rule?

作为标题,我尝试使用以下命令来做到这一点:

az network nic ip-config inbound-nat-rule add --ip-config-name default-ip-config 
  -g <resource_group> --nic-name <nic_name>  --inbound-nat-rule 
  subscriptions/<subscription_id>/resourceGroups/<rg_name>/providers/Microsoft.Network/loadBalancers/<lb_name>/inboundNatRules/<nat_rule_name>

然后我得到以下信息:

NoneType' object is not iterable
Traceback (most recent call last):
  File "/Users/goodwill/lib/azure-cli/lib/python2.7/site-packages/azure/cli/main.py", line 37, in main
    cmd_result = APPLICATION.execute(args)
  File "/Users/goodwill/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/application.py", line 157, in execute
    result = expanded_arg.func(params)
  File "/Users/goodwill/lib/azure-cli/lib/python2.7/site-packages/azure/cli/core/commands/__init__.py", line 343, in _execute_command
    raise ex
TypeError: 'NoneType' object is not iterable

有人知道出了什么问题吗?

after you add the rule you need to do the association from the nic end to add the nic private IP to the rule

旧版 Xplat-CLI 和 CLI 2.0 之间存在一些差异,这里是将 现有 NIC 关联到负载均衡器 NAT 规则的脚本:

az network nic ip-config update -g vm --nic-name nic-name --name ipconfigname --lb-name lbname --lb-inbound-nat-rules natrule

如果你想创建一个新的虚拟机网卡到这个NAT规则,请参考这个link