The Azure CLI 2.0 has become quite nice compared to the limited usefulness of the first release. It has however some quirks - as each software has.

One specific one that struck me hard is the procedure how to combine Loadbalancers with Networkcards (NICs).

Let’s assume you want to set up a cluster of some nodes, behind a Azure Loadbalancer. Not an uncommon scenario.

There are som tutorials on the Internet covering this exact szenario. However, when executed using the Azure CLI 2.0 instead of powershell or the website, the outcome is quite different.

When creating a machine using the CLI, the host is created including a NIC connected to it. That is need and quite useful, but puts you into problems when you try to assign a network to that card after the host has been created and came up.

$ az vm create --name host1 [...]

If you then try updating the NIC settings TODO, you fill fail. I actually had a talk on the phone with the Azure Support about this and they mentioned they never used this approach. Neither did they use the Azure CLI. So whenever they created a host via Windows Powershell, the hosts did not have a NIC. That needed to be created separately and could be attached to the Loadbalancer network before it got assigned to the host.

Splitting the host creation with the CLI into two steps got the expected result:

  • create the NIC first
  • create the host, using the previously created NIC
$ az network nic create \
    --name <nicname> \
    --resource-group <rg> \
    --vnet <vnet> \
    --subnet <subbnet> \
    --public-ip-address ""
$ az vm create \
    --name <hostname> \
    --resource-group <rg> \
    --location <location> \
    --image UbuntuLTS \
    --nics <nicname> \