Improve experience adding/removing VMs/NICs to/from load balancers
See original GitHub issueCouple of suggestions for improving the experience when working with load balancers. Or set me straight if I’m just doing it all wrong 😃
To add or remove a VM from the load balancer, you actually work with a virtual NIC resource. Logically, and architecturally, this makes sense. But really, it’s the VM you’re working on.
az vm create
allows you to specify --nsg
or --subnet
to hook a VM up to existing network resources. Adding the option for --lb-name
and --lb-backend-pools
would be awesome. Or am I missing how to create a VM, let a new virtual NIC be created, and add it to a load balancer? Now it seems like you have to create the NIC with:
az network nic create \
--resource-group myResourceGroup \
--name myNic \
--vnet-name myVnet \
--subnet mySubnet \
--network-security-group myNetworkSecurityGroup \
--lb-name myLoadBalancer \
--lb-address-pools myBackEndPool
And then create the VM with az vm create --nics myNic [...]
Kind of along the same lines, adding or removing a VM from a load balancer means working with the virtual NIC resource. Cool, a VM could have more than virtual NIC, but then it seems like I have to obtain the ID for a virtual NIC, strip to get just the name, and then remove or add from the load balancer. I can get the ID for a virtual NIC from a VM, but az network nic ip-config address-pool remove
or address-pool add
wants a NIC name, not ID. So I end up with:
vmnic=$(az vm show --resource-group myResourceGroup --name myVM \
--query [networkProfile.networkInterfaces[*].id] --output tsv | sed 's:.*/::')
az network nic ip-config address-pool remove \
--resource-group myResourceGroup \
--nic-name $vmnic \
--ip-config-name ipConfig1 \
--lb-name myLoadBalancer \
--address-pool myBackEndPool
Or again, am I missing an easier way here?
Suggestion would be to either
- allow
az network nic ip-config add | remove
to accept something like--nic-id
rather than--nic-name
, or - allow for
--vm-name
and then take the first virtual NIC attached to the VM.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
Hi @iainfoulds the help text for
nic ip-config backend-address add
:So you can either specify --nic-name + --resource-group + --ip-config-name OR --ids, which should accept the ID of the nic IP config.
Due to the perceived amount of engineering effort needed to simplify these scenarios balanced against the lack of customer asks in this area, we have decided to not pursue these changes.