0

We use Bicep to manage our DNS records.

I have recently set up an Azure Front Door profile with custom domains, which is working fine. One of the custom domains is an apex domain, so the Azure portal creates a DNS A record which points to the Azure resource: i.e. the Front Door profile/endpoint.

The portal provides a nice UI to manage this. Because we manage our DNS using Bicep, we need to add this A record definition to our Bicep file to avoid accidentally reverting it in future deployments.

I can find no documentation on how to do this. I have tried something like this:

resource aliasRecord 'Microsoft.Network/dnsZones/A@2018-05-01' = {
  parent: dnsZone
  name: '@'
  properties: {
    TTL: 3600
    targetResource: {
      id: '/subscriptions/{guid}/resourcegroups/{rgName}/providers/Microsoft.Network/frontdoors/{profileName}/frontendendpoints/{endpointName}'
    }
  }
} 

I get a "Reference records are not supported for resource" error. I can't find any guidance on how to reference the Front Door endpoint here.

3
  • Azure DNS alias records can only point to the Front Door profile, not a specific frontend endpoint—use a CNAME for subdomains (sub.example.com) or alias A for apex (example.com), but referencing individual frontend endpoints is not supported @jamesfm Commented Mar 7 at 7:23
  • Hi Vinay, are you sure? In the Azure portal for the DNS A (alias) record I am able to select from a list of the endpoints on each front door profile. Do you have any documentation on this point? Commented Mar 7 at 9:36
  • could you share a screenshot the dns configuration from azure portal? Commented Mar 8 at 3:50

1 Answer 1

0

After a day, I asked this same question on MS Q&A. The helpful answer was to:

  • copy the json template for the DNS zone

  • decompile it into Bicep and see how the alias A record is created

I did this and it revealed the errors in my target resource id, which should have been:

'/subscriptions/{guid}/resourceGroups/{rgName}/providers/Microsoft.Cdn/profiles/{frontDoorName}/afdendpoints/{endpointName}'

Once I tried it with this syntax it worked fine.

A useful approach when you can't find any documentation! See also:

https://learn.microsoft.com/en-us/answers/questions/2202284/how-can-i-use-bicep-to-create-an-azure-dns-alias-r

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.