none
Error while Deploying a Template to create a VNet with Custom DNS IP's

    Question

  • Hi All,

    I am trying to create a vnet with a subnet. This vnet needs to be configured to have its own custom DNS IP's. But this fails.

    Below is the ARM Template that i am using.

    =======================================================================

    {
        "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
          "location": {
              "type": "string",
              "metadata": {
                  "Description": "The region to deploy the resources into"
              }
          },
          "vnetname": {
              "type": "string",
              "metadata": {
                  "Description": "The name of the Virtual Network"
              }
          },
          "vnetaddressrange":{
              "type": "string",
              "metadata": {
                  "Description": "The Address Prefix of the Vnet in CIDR notation"
              }
          },
          "subnetname":{
              "type": "string",
              "metadata": {
                  "Description": "The name of the subnet"
              }
          },
          "subnetaddressrange":{
              "type": "string",
              "metadata": {
                  "Description": "The Address Prefix of the subnet in CIDR notation"
              }
          },
          "dnsips":{
              "type": "array",
              "metadata": {
                  "Description": "The IP addresses for the DNS Servers"
              }
          }
        },
        "variables": {},
        "resources": [
          {
          "type": "Microsoft.Network/virtualNetworks",
          "name": "[parameters('vnetname')]",
          "apiVersion": "2018-02-01",
          "location": "[parameters('location')]",
          "properties": {
              "addressSpace": {
                  "addressPrefixes": [
                      "[parameters('vnetaddressrange')]"
                  ]
              },
              "dhcpOptions": {
                  "dnsServers": [
                      "[parameters('dnsips')]"
                  ]
              },
              "subnets": [
                  {
                      "name": "[parameters('subnetname')]",
                      "properties": {
                      "addressPrefix": "[parameters('subnetaddressrange')]"
                      }
                  }
              ],
              "virtualNetworkPeerings": [],
              "enableDdosProtection": false,
              "enableVmProtection": false
          }
          }
          ]
      }

    =========================================================

    The screenshot of the page where I am inputting the values. As soon as i hit Purchase, it gives me validation errors. Below is the screenshot of the same.

    ==================================================================

    Now if i change the parameter "dnsips"  type to "string", it works but only with a single value and not more than one. 

    Is there something wrong with the syntax or is there a specific way that i need to input the array value for this to work?

    Any clue or guidance pointing what I am doing wrong, would a great help for me.

    Thank You.


    Binoy

    Tuesday, August 14, 2018 9:50 AM

Answers

  • Hi,

    In your template, specify the DNS IPs like this:  "dnsServers": "[parameters('dnsips')]"

    Then, specify the DNS IPs like this:  [  "10.0.0.5",  "10.0.0.6"  ]

    Good luck!

    Jonathan (www.opsgility.com)

    Tuesday, August 14, 2018 12:21 PM
    Moderator

All replies

  • Hi,

    In your template, specify the DNS IPs like this:  "dnsServers": "[parameters('dnsips')]"

    Then, specify the DNS IPs like this:  [  "10.0.0.5",  "10.0.0.6"  ]

    Good luck!

    Jonathan (www.opsgility.com)

    Tuesday, August 14, 2018 12:21 PM
    Moderator
  • Perfect that worked. Thanks Jonathan.

    Binoy

    Wednesday, August 15, 2018 12:36 AM