Bicep : how to setup DNSzone/record for private endpoint

David Vanden Bussche 30 Reputation points
2023-12-06T13:52:30.7366667+00:00

for an azure appservice I created a private endpoint through bicep.

Now I want to setup a private DNSzone record for this endpoint in bicep.

what is the correct way to do this :

resource privateDnsZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2021-05-01' = {
  location: resourceGroup().location
  name: '${peName}/default'
  properties: {
    privateDnsZoneConfigs: [
      {
        name: '${peName}-dns'
        properties: {
          privateDnsZoneId: privateDnsZones_privatelink.id
        }
      }
    ]
  }
}

or

resource privateDnsZones_privatelink_apps 'Microsoft.Network/privateDnsZones/A@2020-06-01' = {
  parent: privateDnsZones_privatelink
  name: toLower(recordname)
  properties: {
    ttl: 3600
    aRecords: [
      {
        ipv4Address: '10.x.x.x'
        
      }
    ]
  }
}
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,974 questions
0 comments No comments
{count} votes

Accepted answer
  1. Luis Arias 8,621 Reputation points Volunteer Moderator
    2023-12-06T20:52:22.1+00:00

    Hello David Vanden Bussche,

    You will need to use the Microsoft.Network/privateDnsZones resource and include inside it the virtual network link to your vnet that will resolve the name.

    Take on consideration the private dns zone name from the list of documentation:

    https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-dns

    Example: privatelink.azurewebsites.net

     resource privateDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' = {
     //Include the dns zone name
       name: privateDnsZoneName
       location: 'global'
     	// You require this section to link the Private Dns Zone to vnet
       resource privateDnsZoneVirtualNetworkLink 'virtualNetworkLinks@2020-06-01' = {
         name: vnetLinkName
         location: 'global'
         properties: {
    		// This is a bool value
           registrationEnabled: autoregistrationEnabled
           virtualNetwork: {
    		// Use the your vnet Id
             id: virtualNetworkId
           }
         }
       }
     }
    
    // Create PrivateEndpointDnsZoneGroup service 
     resource privateEndpointDsnZoneGroupResource 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2020-07-01' = {
       name: '<YOUR PRIVATE ENDPOINT NAME>/default'
       properties: {
         privateDnsZoneConfigs: [
           {
             name: privateDnsZoneName
             properties: {
               privateDnsZoneId: privateDnsZone.Id
             }
           }
         ]
       }
       dependsOn: [
         <Your private Endpoint resource or module>
       ]
     }
    
    

    Here additional documentation:

    https://learn.microsoft.com/en-us/azure/templates/microsoft.network/privatednszones?pivots=deployment-language-bicep https://learn.microsoft.com/en-us/azure/templates/microsoft.network/privatednszones/virtualnetworklinks?pivots=deployment-language-bicep

    Note: Your private endpoint bicep code need to consider the privateLinkServiceId

    Let me know if you need additional help.

    Luis.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.