4

I have a set of Azure Resource Manager and DSC scripts that I use to deploy a new VM to Azure and then make it a domain controller for a new domain, these have worked fine for some time, but it's now failing the DSC part.

I believe the issue is down to the alias assigned to the VM's network interface. My DSC script has the following section to change the VM's to point to its self for DNS:

  xDnsServerAddress DnsServerAddress 
        { 
            Address        = '127.0.0.1' 
            InterfaceAlias = 'Ethernet'
            AddressFamily  = 'IPv4'
        }

The problem seems to occur because the virtual machines network interface is actually created with an Alias of "Ethernet 2" or "Ethernet 3", and the alias needs to match. There are no other network cards in the VM, and at no point have I added any. The thing that makes it more odd is that if I try and rename this network interface to "Ethernet" it tells me there is already a network interface with that name, even though I can find no reference to this.

So, to get this work to work I need to either find out why the interface is not just being named "Ethernet" or a way to write the DSC script so that it it can set the DNS for the only network interface on the machine. Any ideas.

Edit:

This seems to be related to the fact that device manager has labled the NIC as network adapter #2, but there is no adapter #1 nor can I see any reason why any would have been added during the deployment process. This seems to occur on all the VM's in this deployment (but it only breaks the DC).

Network Cards

I have included the ARM script I use to create this below as well, its pretty much take straight from the MS Github templates.

{
      "apiVersion": "2015-05-01-preview",
      "type": "Microsoft.Network/networkInterfaces",
      "name": "dc-nif",
      "location": "[resourceGroup().location]",
      "dependsOn": [
        "Microsoft.Network/virtualNetworks/vnet"
      ],
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig",
            "properties": {
              "privateIPAllocationMethod": "Static",
              "privateIPAddress": "[variables('dnsServerPrivateIp')]",
              "subnet": {
                "id": "[variables('BackEndSubnet-id')]"
              }
            }
          }
        ]
      }
    },

    {
      "apiVersion": "2015-05-01-preview",
      "type": "Microsoft.Compute/virtualMachines",
      "name": "dc-vm",
      "location": "[resourceGroup().location]",
      "dependsOn": [
        "[resourceId('Microsoft.Storage/storageAccounts',parameters('newStorageAccountName'))]",
        "[resourceId('Microsoft.Network/networkInterfaces','dc-nif')]"
      ],
      "properties": {
        "hardwareProfile": {
          "vmSize": "Standard_A2"
        },
        "osProfile": {
          "computername": "dc",
          "adminUsername": "[parameters('adminUsername')]",
          "adminPassword": "[parameters('adminPassword')]"
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "[variables('imagePublisher')]",
            "offer": "[variables('imageOffer')]",
            "sku": "[variables('imageSku')]",
            "version": "latest"
          },
          "osDisk": {
            "name": "osdisk",
            "vhd": {
              "uri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net/vhds/dc-vm-os-disk.vhd')]"
            },
            "caching": "ReadWrite",
            "createOption": "FromImage"
          },
          "dataDisks": [
            {
              "name": "dc-vm-data-disk",
              "vhd": {
                "Uri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net/vhds/dc-vm-data-disk.vhd')]"
              },
              "caching": "None",
              "createOption": "Empty",
              "diskSizeGB": "100",
              "lun": 0
            }
          ]
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces','dc-nif')]"
            }
          ]
        }
      },
      "resources": [
        {
          "type": "Microsoft.Compute/virtualMachines/extensions",
          "name": "dc-vm/createadforest",
          "apiVersion": "2015-05-01-preview",
          "location": "[resourceGroup().location]",
          "dependsOn": [
            "[resourceId('Microsoft.Compute/virtualMachines', 'dc-vm')]"
          ],
          "properties": {
            "publisher": "Microsoft.Powershell",
            "type": "DSC",
            "typeHandlerVersion": "1.10",
            "settings": {
              "ModulesUrl": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/active-directory-new-domain/CreateADPDC.ps1.zip",
              "ConfigurationFunction": "CreateADPDC.ps1\\CreateADPDC",
              "Properties": {
                "DomainName": "[parameters('domainName')]",
                "AdminCreds": {
                  "UserName": "[parameters('adminUsername')]",
                  "Password": "PrivateSettingsRef:AdminPassword"
                }
              }
            },
            "protectedSettings": {
              "Items": {
                "AdminPassword": "[parameters('adminPassword')]"
              }
            }
          }
        }
      ]
    },

1 Answer 1

2

It is possible to pass variables to DSC parameters allowing you to use dynamic information, in this case by passing any assumptions of a host's network interface(s) status.

e.g.

 xDnsServerAddress DnsServerAddress
    { 
        Address        = '127.0.0.1' 
        InterfaceAlias = $firstActiveAdapter.InterfaceAlias
        AddressFamily  = 'IPv4'
    }

Where the $firstActiveAdapter variable was created with the following.

$firstActiveAdapter = Get-NetAdapter -InterfaceDescription "Microsoft Hyper-V Network Adapter*" | Sort-Object -Property ifIndex | Select-Object -First 1

The above command will pull the first adapter from the list of installed adapter by order of the interface index property.

The command will have to be run at a time when at least one network adapter is present on the system, it does not yet have to be active on the network for the command to succeed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .