DNS Resolver

Overview

The DNS resolver resource provides a DNS endpoint for resources that have IP connectivity to a virtual network but aren’t directly attached to it such as VPN or ExpressRoute clients. It also provides outbound DNS resolution to enable resources in the virtual network to resolve DNS using external DNS servers, such as an on-premise DNS.

  • DNS Resolver (Microsoft.Network/dnsResolvers)
  • DNS Resolver Inbound Endpoint (Microsoft.Network/dnsResolvers/inboundEndpoints)
  • DNS Resolver Outbound Endpoint (Microsoft.Network/dnsResolvers/outboundEndpoints)
  • DNS Forwarding Ruleset (Microsoft.Network/dnsForwardingRulesets)
  • DNS Forwarding Rules (Microsoft.Network/dnsForwardingRulesets/forwardingRules)
  • DNS Forwarding Virtual Network Links (Microsoft.Network/dnsForwardingRulesets/virtualNetworkLinks)

DNS Resolver Builder Keywords

Applies ToKeywordPurpose
dnsResolvernameSets the name of the DNS resolver.
dnsResolvervnetSets the virtual network where the of the DNS resolver is attached.
dnsResolverlink_to_vnetLinks the resolver to an existing virtual network.
dnsResolverinbound_subnetIf set, an inbound endpoint will be generated for this subnet with dynamic IP allocation. The subnet can only contain DNS resolver resources.
dnsResolveradd_inbound_endpointsAdd inbound endpoints to subnets and specify static or dynamic IP allocation.
dnsResolveroutbound_subnetIf set, an outbound endpoint will be generated for this subnet. The subnet can only contain DNS resolver resources.
dnsResolveradd_outbound_endpointsAdd outbound endpoints to additional subnets.
dnsResolverdepends_onDeploy this DNS resolver after another resource is successfully deployed.
dnsResolveradd_tagAdds a tag to this resource.
dnsResolveradd_tagsAdds a set of tags to this resource.
dnsInboundEndpointnameSets the name of the DNS resolver inbound endpoint.
dnsInboundEndpointdns_resolverAdd the inbound endpoint to a DNS resolver in the same deployment.
dnsInboundEndpointlink_to_dns_resolverLinks to an existing DNS resolver.
dnsInboundEndpointsubnetSpecify a subnet in this deployment where the inbound endpoint will be added.
dnsInboundEndpointlink_to_subnetCreate the inbound endpoint in an existing subnet.
dnsInboundEndpointadd_dynamic_ipAdds a dynamically assigned IP for the inbound endpoint in the subnet.
dnsInboundEndpointadd_static_ipAdds a statically assigned IP for the inbound endpoint in the subnet.
dnsInboundEndpointdepends_onDeploy this DNS inbound endpoint after another resource is successfully deployed.
dnsInboundEndpointadd_tagAdds a tag to this resource.
dnsInboundEndpointadd_tagsAdds a set of tags to this resource.
dnsOutboundEndpointnameSets the name of the DNS resolver outbound endpoint.
dnsOutboundEndpointdns_resolverAdd the outbound endpoint to a DNS resolver in the same deployment.
dnsOutboundEndpointlink_to_dns_resolverLinks to an existing DNS resolver.
dnsOutboundEndpointsubnetSpecify a subnet in this deployment where the outbound endpoint will be added.
dnsOutboundEndpointlink_to_subnetCreate the outbound endpoint in an existing subnet.
dnsOutboundEndpointdepends_onDeploy this DNS outbound endpoint after another resource is successfully deployed.
dnsOutboundEndpointadd_tagAdds a tag to this resource.
dnsOutboundEndpointadd_tagsAdds a set of tags to this resource.
dnsForwardingRulesetnameSets the name of the DNS forwarding ruleset.
dnsForwardingRulesetadd_resolver_outbound_endpointsApplies this ruleset to one or more DNS resolver outbound endpoints in the same deployment.
dnsForwardingRulesetadd_rulesAdds one or more rules to forward DNS domain resolution to a DNS endpoint (IP and port).
dnsForwardingRulesetadd_vnet_linksLinks this ruleset to one or more virtual networks to provide DNS resolution to resources in that virtual network. It does not need to be the same vnet where the resolver is created, but it must be in the same region.
dnsForwardingRulesetdepends_onDeploy this DNS forwarding ruleset after another resource is successfully deployed.
dnsForwardingRulesetadd_tagAdds a tag to this resource.
dnsForwardingRulesetadd_tagsAdds a set of tags to this resource.
dnsForwardingRulenameSets the name of the DNS forwarding rule.
dnsForwardingRuleforwarding_ruleset_idAdds the rule an a forwarding ruleset defined in the same deployment.
dnsForwardingRuledomain_nameSpecifies the domain to which the rules apply. A trailing dot ‘.’ will be appended if not added since forwarding rules require it.
dnsForwardingRulestateEnable or disable a rule.
dnsForwardingRuleadd_target_dns_serversSpecify one or more DNS servers by IP and port as System.Net.IPEndPoint objects. These will be used to resolve requests for the domain_name in this rule.

Example - Inbound Endpoint

To provide a private resolver for resources in a virtual network, add a subnet that is delegated to DNS resolvers and specify that as the inbound_subnet on a dnsResolver resource.

#r "nuget: Farmer"

open Farmer
open Farmer.Builders
open Farmer.Network

arm {
    add_resources
        [
            vnet {
                name "mynet"
                add_address_spaces [ "100.72.2.0/24" ]

                add_subnets
                    [
                        subnet {
                            name "resolver-subnet"
                            prefix "100.72.2.240/28"
                            add_delegations [ SubnetDelegationService.DnsResolvers ]
                        }
                    ]
            }
            dnsResolver {
                name "my-dns-resolver"
                vnet "mynet"
                inbound_subnet "resolver-subnet"
            }
        ]
}

Example - Outbound Endpoint and Ruleset

To resolve DNS in a virtual network with a route to an on-premise DNS server (e.g. a vNet with a VPN gateway to on-premise), add a subnet that is delegated to DNS resolvers and specify that as the outbound_subnet on a dnsResolver resource. Define rules for the domains that should be forwarded to the on-premise DNS servers.

#r "nuget: Farmer"

open Farmer
open Farmer.Builders
open Farmer.Network

arm {
    add_resources
        [
            vnet {
                name "mynet"
                add_address_spaces [ "100.72.2.0/24" ]

                add_subnets
                    [
                        subnet {
                            name "resolver-subnet"
                            prefix "100.72.2.240/28"
                            add_delegations [ SubnetDelegationService.DnsResolvers ]
                        }
                    ]
            }
            dnsResolver {
                name "my-dns-resolver"
                vnet "mynet"

                add_outbound_endpoints
                    [
                        dnsOutboundEndpoint {
                            name "outbound-dns"

                            link_to_subnet (
                                Farmer.Arm.Network.subnets.resourceId (
                                    ResourceName "mynet",
                                    ResourceName "resolver-subnet"
                                )
                            )
                        }
                    ]
            }
            dnsForwardingRuleset {
                name "route-dns-requests"
                depends_on [ Farmer.Arm.Network.virtualNetworks.resourceId (ResourceName "mynet") ]

                add_resolver_outbound_endpoints
                    [
                        // list of outbound endpoint IDs. These must be in a subnet that
                        // can reach the endpoint IPs for rules in this ruleset.
                        Farmer.Arm.Dns.dnsResolverOutboundEndpoints.resourceId (
                            ResourceName "my-dns-resolver",
                            ResourceName "outbound-dns"
                        )
                    ]

                add_vnet_links
                    [
                        // List of vnet IDs that will resolve domains using this ruleset.
                        Farmer.Arm.Network.virtualNetworks.resourceId (ResourceName "mynet")
                    ]

                add_rules
                    [
                        // List of rule sets for domains in the on-premise network.
                        dnsForwardingRule {
                            name "rule-1"
                            domain_name "example.com"
                            state Enabled

                            add_target_dns_servers
                                [
                                    // On-premise DNS servers IP addresses and ports.
                                    System.Net.IPEndPoint.Parse("192.168.100.74:53")
                                    System.Net.IPEndPoint.Parse("192.168.100.75:53")
                                ]
                        }
                    ]
            }
        ]
}