I am trying to add a second network adapter to an Azure Virtual machine scale set.
This is the code I'm using:
Add-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
$vnetname = "conf-virtual-network-interlink"
$loc = "West Europe"
$backendSubnetName = "default"
$backendSubnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name $backendSubnetName -AddressPrefix "10.1.0.0/24"
echo "backendSubnetConfig: "$backendSubnetConfig
$vnet = New-AzureRmVirtualNetwork -ResourceName $vnetname -Location $loc -ResourceGroupName "resourcegroup-confluence-jira-datacenter" -Subnet $backendSubnetConfig -AddressPrefix "10.1.0.0/24"
echo "vnet: "$vnet
$subnetId = (Get-AzureRmVirtualNetworkSubnetConfig -Name $backendSubnetName -VirtualNetwork $vnet).Id
echo "subnetId: "$subnetId
$ipCfg = New-AzureRmVmssIPConfig -Name 'eth1' -SubnetId $subnetId
echo "ipCfg: "$ipCfg
$backendSubnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $backendSubnetName -VirtualNetwork $vnet
echo "backendSubnet: "$backendSubnet
$vmss = Get-AzureRmVmss -ResourceGroupName resourcegroup-confluence-jira-datacenter -VMScaleSetName confcluster
echo "vmss: "$vmss
Add-AzureRmVmssNetworkInterfaceConfiguration -Name $backendSubnet -Primary $false -IPConfiguration $ipCfg -VirtualMachineScaleSet $vmss
Update-AzureRmVmss -ResourceGroupName "resourcegroup-confluence-jira-datacenter" -Name "confcluster" -VirtualMachineScaleSet $vmss
But I am getting the error message:
Update-AzureRmVmss : VM scale set /subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/RESOURCEGROUP-CONF LUENCE-JIRA-DATACENTER/providers/Microsoft.Compute/virtualMachineScaleSets/confcluster cannot reference subnets /subscr iptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/resourcegroup-confluence-jira-datacenter/providers/Microsof t.Network/virtualNetworks/confvnet/subnets/confclustersubnet,/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resour ceGroups/resourcegroup-confluence-jira-datacenter/providers/Microsoft.Network/virtualNetworks/conf-virtual-network-inte rlink/subnets/default from different virtual networks. ErrorCode: VMScaleSetCannotReferenceSubnetsFromDifferentVirtualNetworks ErrorMessage: VM scale set /subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/RESOURCEGROUP-CONFLUENCE- JIRA-DATACENTER/providers/Microsoft.Compute/virtualMachineScaleSets/confcluster cannot reference subnets /subscriptions /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/resourcegroup-confluence-jira-datacenter/providers/Microsoft.Netwo rk/virtualNetworks/confvnet/subnets/confclustersubnet,/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroup s/resourcegroup-confluence-jira-datacenter/providers/Microsoft.Network/virtualNetworks/conf-virtual-network-interlink/s ubnets/default from different virtual networks. ErrorTarget: StatusCode: 400 ReasonPhrase: Bad Request OperationID : ebdcd379-2dba-4a2d-97a8-52c7870a8755 In X:\JIRA_Confluence_Migration\PowerShell\network-interfaces-azure.ps1:49 Zeichen:1 + Update-AzureRmVmss -ResourceGroupName "resourcegroup-confluence-jira- ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Update-AzureRmVmss], ComputeCloudException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss
But my intention actually is to add two different network adapters from the different virtual networks.