1
votes

I have successfully deployed a VMSS with an AD server in the same VLAN. However, when I try to deploy a second VMSS it create a new virtual network, placing it away from my existing AD.

How do I deploy the second VMSS into the same virtual network as the first and AD? If I edit a template to have the same virtual network as the existing one, then deploy it, will the deployment be into the existing virtual network or will it attempt to create a new one with the same name and fail or duplicate it?

Alternatively, is there any way to migrate the NIC in a VMSS to another network? I can't find a cmdlet to do it and in the web interface it only shows the virtual network created at deployment in the drop-down and not the original virtual network.

1

1 Answers

1
votes

If you deploy a template that has an identical vnet configuration a second time it will essentially no-op. If you change the config slightly on an existing work it will attempt to update that config.

Essentially what you want to do here is author the template such that it references the existing network via the NICs and not define the network itself. Your declaration is that the network "exists" so you do not need to define it only reference it. This is a snippet of the JSON:

      "networkProfile": {
        "networkInterfaceConfigurations": [
          {
            "name": "vmss-nic",
            "properties": {
              "primary": true,
              "ipConfigurations": [
                {
                  "name": "vmss-ipconfig",
                  "properties": {
                    "subnet": {
                      "id": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'), '/subnets/', variables('subnetName'))]"
                    }

The "id" property is the resourceId of the subnet for the vnet you want to place the VMSS in. If the vnet is in the same resource group as the VMSS you can shorten that expression to simply:

Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'), '/subnets/', variables('subnetName')

But the fully qualified id will work in all scenarios.

re: moving the VMSS, you can always try by deploying a template configured as above. Same VMSS name in the same RG but with a different network profile.

HTH