Search code examples
azureazure-resource-managerazure-dns

Cannot create azure private dns A record with its ip by using ARM template


I am trying to create an A record in an Azure private DNS Zone with an ARM template. The creation of the record is successful but without its IP, neither TTL. My template is below:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "DNSZoneName": {
      "type": "string",
      "defaultValue": "privatelink.database.windows.net",
      "metadata": {
        "description": "The name of the DNS zone. Must have at least 2 segements, e.g. hostname.org"
      }
    },
    "newRecordName": {
      "type": "string",
      "defaultValue": "pe-sql3",
      "metadata": {
        "description": "The name of the DNS record to be created. The name is relative to the zone, not the FQDN."
      }
    }
  },

  "resources": [
    {

      "type": "Microsoft.Network/privateDnsZones/A",
      "apiVersion": "2018-09-01",
      "name": "[concat(parameters('DNSZoneName'), '/', parameters('newRecordName'))]",
      "location": "global",
      "properties": {
        "TTL": 3600,
        "ARecords": [
          {
            "ipv4Address": "10.0.0.1"
          }
        ]
      }
    }

  ]
}

My command is New-AzResourceGroupDeployment -ResourceGroupName myRg -TemplateFile deploy.json

Here is the screenshot of the A record from the portal: enter image description here

Any idea?


Solution

  • I was writing TTL and ARecords in capital letter. That should have been with ttl and aRecords:

        "properties": {
            "ttl": 3600,
            "aRecords": [
                {
                    "ipv4Address": "1.2.3.4"
                }
            ]
        }
    }
    

    But the thing is that when it is written with capital letters, the REST API doesn’t throw error and accept the request. Normally, it should return http 400 error.

    Anyway, my problem is solved.