2

I am trying to add a second subnet to a Azure Virtual Machine Scale Set using PowerShell.

The code I'm using is:

Add-AzureRmAccount

Select-AzureRmSubscription -SubscriptionId "XXXXXXXXXXXXXXXXXXXXXXXXXXX"


$vnetname = "confvnet"

$loc = "West Europe"

$backendSubnetName = "conf-jira-interlink"

$backendSubnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name $backendSubnetName -AddressPrefix "10.1.0.0/24"

echo "backendSubnetConfig: "$backendSubnetConfig

$vnet = Get-AzureRmVirtualNetwork -Name $vnetname -ResourceGroupName "resourcegroup-confluence-jira-datacenter"

echo "vnet: "$vnet

Add-AzureRmVirtualNetworkSubnetConfig -Name $backendSubnetName -VirtualNetwork $vnet -AddressPrefix "10.1.0.0/24"

$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" -VMScaleSetName "confcluster" -VirtualMachineScaleSet $vmss

But I am getting the error message

Update-AzureRmVmss : Cannot parse the request.
ErrorCode: InvalidRequestFormat
ErrorMessage: Cannot parse the request.
ErrorTarget:
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : 94e52a04-67c4-4390-bbea-74849ccce4ac
In X:\JIRA_Confluence_Migration\PowerShell\network-interfaces-azure-same-vnet.ps1:45 Zeichen:1
+ Update-AzureRmVmss -ResourceGroupName "resourcegroup-confluence-jira- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Update-AzureRmVmss], ComputeCloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss

on the command Update-AzureRmVmss.

Can anyone help me how I am using the Update-AzureRmVmss command wrong?

Joy Wang
  • 39,905
  • 3
  • 30
  • 54
Ronny Forberger
  • 393
  • 1
  • 8
  • 23

1 Answers1

2

To add a second subnet to an Azure Virtual Machine Scale Set, most steps you have done are right and you know the subnet should in the same virtual network as the VMSS already in. Just some parameters you can change like below.

Add-AzureRmVmssNetworkInterfaceConfiguration -Name a_string_name -Primary $false -IPConfiguration $ipCfg -VirtualMachineScaleSet $vmss

The parameter -Name should have a string value. See it Add-AzureRmVmssNetworkInterfaceConfiguration.

And there is also a step you need to do. It's that you need to deallocate the VMSS and then update the VMSS. It cannot support update the VMSS in the running state.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39