StackExchange / dnscontrol

Infrastructure as code for DNS!
https://dnscontrol.org/
MIT License
3.08k stars 390 forks source link

Azure DNS - Add additional nameserver to zone returns error about multiple entries #3088

Open fabienmazieres opened 3 weeks ago

fabienmazieres commented 3 weeks ago

Describe the bug

Adding nameserver entries to Azure public DNS zone fails to add the additionnal server, it returns error message "The list of record sets of type 'NS' may not contain multiple entries with the same 'nsdname'". I want to add extra name server as I intend to host this zone on 2 providers.

To Reproduce

I use the following dnsconfig.js:

var REG_NONE = NewRegistrar("none");
var DNS_AZURE = NewDnsProvider("azuredns_main");

D("example.co.uk", REG_NONE, DnsProvider(DNS_AZURE),
    // Top-level domain configuration
    NAMESERVER_TTL("172800"), // 2 days

    // Azure DNS name servers
    NAMESERVER("ns1-01.azure-dns.com."),
    NAMESERVER("ns2-01.azure-dns.net."),
    NAMESERVER("ns3-01.azure-dns.org."),
    NAMESERVER("ns4-01.azure-dns.info."),

    // Other provider
    NAMESERVER("ns1.other.provider.net."),

    // Records
    A("test", "1.2.3.4"),
    END);

when using preview, it calculate the changes as expected:

PS C:\Users\DNSasCode> dnscontrol preview
******************** Domain: example.co.uk
1 correction (azuredns_main)
#1: + CREATE example.co.uk NS ns1.other.provider.net. ttl=172800
Done. 1 corrections.

but push returns an error message

PS C:\Users\N18180\source\PlatformEngineering.DNSasCode> dnscontrol push   
******************** Domain: impersotech.co.uk
2 corrections (azuredns_main)
#1: + CREATE example.co.uk NS ns1.other.provider.net ttl=172800
FAILURE! PUT https://management.azure.com/subscriptions/xxx-yyy/resourceGroups/xxx/providers/Microsoft.Network/dnsZones/example.co.uk/NS/@
--------------------------------------------------------------------------------
RESPONSE 400: 400 Bad Request
ERROR CODE: BadRequest
--------------------------------------------------------------------------------
{
  "code": "BadRequest",
  "message": "The list of record sets of type 'NS' may not contain multiple entries with the same 'nsdname'."
}
--------------------------------------------------------------------------------
[...]

Adding the extra providers in Azure Portal manually works and subsequent preview or push do validate the change was done as expected.

Expected behavior

No error message displayed, additional NS servers added to the @ NS record.

DNS Provider Azure DNS (azuredns_main)

tlimoncelli commented 3 weeks ago

CC @vatsalyagoel

vatsalyagoel commented 2 weeks ago

Looking into the issue

vatsalyagoel commented 4 days ago

@fabienmazieres When adding additional NAMESERVER Records, you don't need to specify the Azure records on the domain.

NAMESERVER("ns1-01.azure-dns.com."), NAMESERVER("ns2-01.azure-dns.net."), NAMESERVER("ns3-01.azure-dns.org."), NAMESERVER("ns4-01.azure-dns.info.")

These will automatically be there when DNSControl gets the zone from AzureDNS