Table of Contents

About

What is a Network Interface? in Azure

Management

Get Id

Get the Nic id from the VM

az.cmd vm show --resource-group myResourceGroup --name myVM -d --o tsv --query "networkProfile.networkInterfaces[].id"
/subscriptions/a3c34725-da090f6b96d44d/resourceGroups/myResrouceGroup/providers/Microsoft.Network/networkInterfaces/MY_MACHINE_01VMNic

Show

az vm nic show --vm-name vmName  --resource-group resourceGName --nic nicId 

Update

Associate the Network Security Group to a VM

az network nic update \
    --resource-group myResourceGroup \
    --name myNic \
    --network-security-group myNetworkSecurityGroup

Network Security Group

Get the Network Security Group Id

az vm nic show --vm-name vmName   --nic nicId --resource-group resourceGroup --query networkSecurityGroup.id
"/subscriptions/a3c34725-da6a-41ac-87fa-06b96d44d/resourceGroups/resrouceGroupName/providers/Microsoft.Network/networkSecurityGroups/NameNSG"