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

Category: azure automation

Question

Binoy Jacob T on Tue, 14 Aug 2018 00:01:57


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.

Replies

VeeraGiri Babu on Wed, 15 Aug 2018 06:59:01


I would suggest you to try the below cmdlets to your scenario:

{

  "$schema":
"https://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"

      }

    },

   
"virtualNetworkName": {

      "type":
"string",

      "metadata":
{

       
"Description": "The name of the Virtual Network"

      }

    },

   
"virtualNetworkAddressRange": {

      "type":
"string",

      "metadata":
{

        "Description":
"The address range of the VNET in CIDR format"

      },

     
"defaultValue": "10.0.0.0/16"

    },

    "subnets": {

      "type":
"array",

      "metadata":
{

       
"Description": "The subnet definition for the VNET"

      }

    },

    "DNSServerAddress":
{

      "type":
"array",

      "metadata":
{

       
"Description": "The DNS address(es) of the DNS Server(s)
used by the VNET"

      }

    }

  },

  "resources": [

    {

      "name":
"[parameters('virtualNetworkName')]",

      "type":
"Microsoft.Network/virtualNetworks",

      "location":
"[parameters('location')]",

     
"apiVersion": "2015-06-15",

     
"properties": {

       
"addressSpace": {

         
"addressPrefixes": [

           
"[parameters('virtualNetworkAddressRange')]"

          ]

        },

       
"dhcpOptions": {

         
"dnsServers": "[parameters('DNSServerAddress')]"

        },

        "subnets":
"[parameters('subnets')]"

      }

    }

  ]

} 

In order to assist best on your query, I would request you to post your query in SO => Azure Resource manager dedicated support. Additionally, adding the [Azure] tag on SO will increase visibility as it is a Microsoft Sponsored tag.

https://stackoverflow.com/questions/tagged/azure-resource-manager

This will assist you with a faster reply to your query.


-----------------------------------------------------------------------------------------------

If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here

Binoy Jacob T on Wed, 15 Aug 2018 08:03:41


Thanks Veera... I go this answered in another the azure networking forum. the input should be in a specific format.

VeeraGiri Babu on Wed, 15 Aug 2018 10:52:29


We are glad to hear that your query is clarified.