Error deploying a Azure Virtual Machine with 2 NICs - Secondary network interface is supported only for deployments on virtual network
Hi all
I have been playing around a lot with Azure lately as I am trying to make the move to cloud based Lync/Skype Labs. Before we go any further, Lync and Skype at this point in time are not supported in Azure!
I have been trying to get a virtual machine with 2 NICs deployed and was hitting a wall for a while. I had been following blogs out there on step by step how to get it going (not word for word obviously :)), and also had been using some Powershell I normally use for deploying a virtual machine with a single NIC. Anyway I was hitting the below error every time I tried to run the New-AzureVM cmdlet.
New-AzureVM : BadRequest: Secondary network interface feature is supported only for deployments on virtual network.
At C:\Users\steve\OneDrive\Azure\Scripts\CreateEdgeVM2.ps1:28 char:1
+ New-AzureVM -ServiceName $serviceName -VMs $newVM -Location $location
I was using the following commands to create the VM.
$vmName = "<YOUR-VM-NAME>"
$serviceName = "<YOUR-SERVICE-FOR-MULTINIC-VMS>"
$username = "<YOURADMIN>"
$vnetName = "<YOUR-VNET>"
$location = "Southeast Asia"
$strIPAddress = “192.168.14.21"
$strIPAddress2="192.168.15.21"
$strAffinityGroup = "<YOUR-AFFINITY-GROUP>"
$images = Get-AzureVMImage | where { $_.ImageFamily –eq “Windows Server 2012 R2 Datacenter” } | Sort-Object –Descending –Property PublishedDate
$newVM = New-AzureVMConfig -Name $vmName -InstanceSize “ExtraLarge” -ImageName $images[0].ImageName -DiskLabel "OS"
Add-AzureProvisioningConfig -Windows -Password XXXXXXX -AdminUsername $username -VM $newVM
Add-AzureNetworkInterfaceConfig -Name "Ethernet1" -SubnetName "DMZInt" -StaticVNetIPAddress $strIPAddress2 -VM $newVM
#set default NIC
Set-AzureSubnet -SubnetNames "DMZPub" -VM $newVM
Set-AzureStaticVNetIP -IPAddress $strIPAddress -VM $newVM
New-AzureVM -ServiceName $serviceName -VMs $newVM -Location $location
New-AzureVM : BadRequest: Secondary network interface feature is supported only for deployments on virtual network." wasn't particularly obvious to me. I was thinking "virtual network"???@aarrgghh isn't azure all virtual networks *lol*. Anyway, what I had been missing was that when using multi-NIC VMs you need to use the -vnetname parameter in the New-AzureVM cmdlet. I hadn't been using that option previously when deploying single NIC VMs and so this had me stumped for a little bit.
So I should have used the command
New-AzureVM -ServiceName $serviceName -VMs$newVM -Location $location -VNetName $vnetName
So as I didn't have a lot of luck bing'ing for this error I figured I would write a quick blog just in case others do the same thing I did.
Happy Skype/Lync and Azure'ing!
Steve