Tuesday, 5 September 2017

Modifying the primary Network Interface on an Azure IaaS VM using Power Shell

When you have a multi-NIC Azure IaaS VM, one of the NIC's must be marked as the "primary" NIC. This can only be configured using Power Shell.

The Azure IaaS VM instance must be in the stopped state before the NIC's can be modified

Stop-AzureRmVM -Name "myNVA" -ResourceGroupName "myNVA"

Set a variable for the Azure IaaS VM you want to interrogate

$vm = Get-AzureRmVm -Name "myNVA" -ResourceGroupName "myNVA"

Display all the network interfaces attached to that Azure IaaS VM

$vm.NetworkProfile.NetworkInterfaces


Set the priority of the Network Interface using the following commands, the primary should be set to “True”

$vm.NetworkProfile.NetworkInterfaces[0].Primary = $false
$vm.NetworkProfile.NetworkInterfaces[1].Primary = $true

Update-AzureRmVM -VM $vm -ResourceGroupName "myNVA"

Instructs Azure to start up the VM
Start-AzureRmVM -ResourceGroupName "myNVA" -Name "myNVA"


Comments system

Disqus Shortname