0
votes

I'm trying to deploy a series of virtual machines to an Azure virtual network, including adding them to a domain with an existing VM acting as the domain controller. In order to do this, I need to set the domain controller as the default DNS server but I can't seem to find the correct way of doing this through an ARM script.

So far I've tried using DHCPoptions and DNSservers to specify my DNS server. However neither has set the DNS server for the network as I expected. The template validates successfully and runs, including provisioning the virtual network and the test VM. However when I check the virtual network, the DNS servers setting is set to: Default (Azure-provided)

I can change the setting manually, however when I run the ARM template again the virtual network is set back to default.

Is there something that I'm missing here or should I be trying a different parameter?

"variables": {
    "dnsservers":  "10.10.10.10"
},
"resources": [
    {
     "apiVersion": "2016-03-30",
     "type": "Microsoft.Network/virtualNetworks",
     "name": "Virtual-Network",
     "location": "[resourceGroup().location]",
     "properties": {
      "addressSpace": {
       "addressPrefixes": "10.10.10.1/24"
       ]
      },
     "dhcpoptions": {
       "dnsServers": "[variables('dnsservers')]"
      {,
      subnets": [
       {
         "name": "Subnet",
         "properties": {
           "addressPrefix": "10.10.10.1/24"
         }
       },
     ]
   }
},
1

1 Answers

1
votes

dnsServers property accepts an array of strings, not a string, so you have to do this:

"variables": {
    "dnsservers": [
        "10.10.10.10"
    ]
},